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

Sublime Text 3 是一款优秀的代码编辑软件。界面简洁,轻巧快速,很受大家的欢迎。

最近开始用他来编辑数据结构的C语言代码,这就需要在新建编译系统。具体方法如下:

首先:

接下来是关键的一步,将以下代码粘贴到弹出的编辑页面中,文件名为 name.sublime-build 形式,name 是新建的编译器名字。

 1 {
 2     "cmd": ["gcc","${file}","-fexec-charset=gbk","-o", "${file_path}/${file_base_name}"],
 3     "file_regex":"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
 4     "working_dir":"${file_path}",
 5     "selector": "source.c",
 6 
 7     "variants":
 8     [
 9     {
10         "name": "Run",
11         "cmd": ["cmd","/c","-fexec-charset=gbk", "gcc", "${file}", "-o", "${file_path}/${file_base_name}","&&", "cmd", "/c","${file_path}/${file_base_name}"]
12         },
13         {
14         "name":"RunInCommand",
15         "cmd": ["cmd","/c", "gcc", "${file}","-fexec-charset=gbk", "-o","${file_path}/${file_base_name}", "&&","start", "cmd", "/c","${file_path}/${file_base_name} & pause"]
16     }
17     ]
18 }

多说一句,网上的编译器代码有很多,有些可能因为版本原因不能成功编译,有些运行后会有编码导致的乱码出现。以上我贴出的代码是经过测试能完美编译和运行的,完全可以放心使用。

原文地址:https://www.cnblogs.com/deepcho/p/sublimetext3-c-program.html