如何在 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/