windows sublime text3编译运行c

一:mingw

由于安装过程中出现无法连接,网上找的一些方法在此。
但转念一想,powershell里不就有gcc吗?!
在这里插入图片描述
具体该种方法不再赘述,感兴趣的小伙伴可以点此链接

二 powershell中运行(推荐)

既然可以在cmd中运行,那么可不可以改成在powershell里运行呢?
参考StackOverflow

1.配置sublime-build

打开sublime text 3
Tools->build system->new build system
输入如下代码

{
    "cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
    "shell": true,

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["start", "powershell", "-NoExit", "${file_path}//${file_base_name}.exe"],
            "shell": true
        }
    ]
}

ctrl+s保存(打开即为默认路径
在这里插入图片描述

2.编译运行

写好的c文件 保存 并ctrl + B
或ctrl shift b 选择模式:
在这里插入图片描述

c_power -run:编译并在powershell中运行
c_power : 编译生成exe文件不运行
在这里插入图片描述

原创文章 1 获赞 1 访问量 67

猜你喜欢

转载自blog.csdn.net/qq_30303857/article/details/106155802