c - 用于编译和运行 .c 文件的 Visual Studio Code 任务

标签 c visual-studio compilation task

如何在 Visual Studio Code(最新版本)中创建任务来编译和运行 .c 文件。
我在网上找到了这个:

    "version": "2.0.0",
    "tasks": [
        {
            "label": "compile and run C",
            "type": "shell",
            "command": "(gcc -g ${file} -o ${fileBasenameNoExtension}) -and (./${fileBasenameNoExtension})",
            "presentation": {
                "reveal": "always",
                "panel": "shared"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

我设法调整它,但它仍然不会同时编译和运行,而是我得到这个:

> Executing task: (gcc -g d:\ISEP\ARQCP\partilha\arqcp19202deg01\pl0_7.c -o pl0_7) -and (./pl0_7) <

False

Terminal will be reused by tasks, press any key to close it.

有没有办法用简单的快捷方式编译和运行我的代码(目前我按 CTRL+SHIFT+B 来“编译并运行”)?

最佳答案

所以我一直在寻找一种方法来做到这一点,我发现了这个简单的扩展:Code Runner .

基本上,它只是为大多数编码语言添加了一个运行代码按钮,这使得它变得更加容易。

关于c - 用于编译和运行 .c 文件的 Visual Studio Code 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58035069/

相关文章:

visual-studio - CMake 到 Qt Creator .pro 文件;从 Qt Creator 构建特定的 CMake 项目

python - 在线编辑Python脚本?

java - 桥接模式——用 Java 编译的好处?

c - 如何为 program.c 创建 makefile 以及如何在实时应用程序接口(interface)中编译和执行

c++ - 为什么这种使用简单加减法的交换不会溢出?

c++ - fprintf/fputs 与大字符串的 cout 性能

visual-studio-2010 - 是否有具有可视分支的 Team Foundation Server GUI 客户端?

c++ - 在链接之前修改 visual studio 生成的程序集

c - 二维数组指针

c - 共享库注入(inject): _dl_relocate_object segfaults