准备环境
为了快捷起见,建议安装Dev-C++,去里面找到MinGW64
然后配置环境变量一直到MinGW64\bin
下
然后通过cmd测试
这样则表示把C和C++编译器环境加入系统环境
配置sublime
接下来我们配置sublime,打开sublime,点击Tools→Build System→New Build System,接下来把里面的东西都删掉~粘贴以下代码
{
"cmd": ["g++","-Wall", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"encoding":"cp936",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", "${file_path}/${file_base_name}"]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"]
}
]
}
配置快捷启动键
点击Perferences→Key Bindings - User,删除所有东西,粘贴如下代码:
[
{
"keys": ["f9"],
"command": "build",
"args": {"variant": "RunInCommand"}
}
]
注意不要有多余的东西哦,然后同样Ctrl+S直接保存即可。如果想改成F5或者F6或者其它,把代码里面的f9改一下就好啦。
敲代码,Ctrl+S保存代码,F9运行,启动cmd运行!完美。