升华文本2可以';你不能运行我的c程序吗?

升华文本2可以';你不能运行我的c程序吗?,c,compiler-construction,editor,sublimetext,C,Compiler Construction,Editor,Sublimetext,我使用的是Windows7,我添加了 { "cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "-lm", "-Wall"], "selector" : "source.c", "shell":true, "working_dir" : "$file_path" } 对于我的c.sublime-build,虽然它可以构建我的程序,但run选项消失了。因此,我无法看到我的简单hello worl

我使用的是Windows7,我添加了

{
    "cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "-lm", "-Wall"],
    "selector" : "source.c",
    "shell":true,
    "working_dir" : "$file_path"
}
对于我的c.sublime-build,虽然它可以构建我的程序,但run选项消失了。因此,我无法看到我的简单hello world程序的输出。

您需要为执行该程序的
Run
选项添加一个。下面是我的g++.sublime构建的样子

{
    "shell_cmd": "g++ \"${file}\" -O3 -std=c++11 -pedantic -Wall -Wextra -Wconversion -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ \"${file}\" -O3 -std=c++11 -pedantic -Wall -Wextra -Wconversion -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
        }
    ]
}

“我的运行”选项生成并运行程序,如果您只想让命令的前半部分运行可执行文件,请将其删除。

正确缩进和组织摘录是确保人们真正阅读它们的一个好方法:)这次为您解决了这个问题