Sublime Text 3 实现C++代码的编译和运行

在数据结构代码的编写中,我选用了优秀的编辑器 Sublime Text 3,但是在实现C++代码的编译和运行上费了一番周折,接下来我贴出 C++ 编译系统的代码,供各位参考。

编译后是在弹出的CMD命令行窗口运行的,因为若在 Sublime Text 3 运行则可能无法实现输入等操作(?)。

 1 {
 2     "encoding": "utf-8",
 3     "working_dir": "$file_path",
 4     "shell_cmd": "g++ -Wall -std=c++11 -fexec-charset=GBK \"$file_name\" -o \"$file_base_name\"",
 5     "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
 6     "selector": "source.c++",
 7  
 8     "variants": 
 9     [
10         {    
11         "name": "Run",
12             "shell_cmd": "g++ -Wall -std=c++11 -fexec-charset=GBK \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
13         }
14     ]
15 }

以上代码也避免了因编码问题导致的乱码现象。