I recommend you to read build document of Sublime Text 2.
Here is the answer. In Sublime, click Tools -> Build System -> New Build System...
For Windows user, type the following code and save:
{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "&&", "${file_base_name}.exe"],
"selector" : "source.c",
"shell" : true,
"working_dir" : "$file_path"
}
For Mac user, type the following code:
{
"cmd" : ["gcc", "-o", "$file_base_name", "$file_name"],
"cmd" : ["./$file_base_name"],
"selector" : "source.c",
"shell" : false,
"working_dir" : "$file_path"
}
For Linux User, copy the following code
{
"cmd" : ["gcc $file_name -o ${file_base_name} && ./${file_base_name}"],
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path"
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…