vscode可以在一个文件交夹运行.c和.cpp吗
时间: 2024-02-11 12:04:52 浏览: 161
是的,在VSCode中可以在一个文件夹中同时运行 .c 和 .cpp 文件。您可以使用以下步骤:
1. 打开VSCode并打开您的项目文件夹。
2. 创建一个名为“tasks.json”的文件,该文件应该在您的项目文件夹中。您可以在VSCode中使用任务管理器来创建此文件。
3. 在“tasks.json”中,您可以创建两个不同的任务来编译您的 .c 和 .cpp 文件。例如:
```json
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile C File",
"type": "shell",
"command": "gcc -o ${fileBasenameNoExtension} ${file}",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$gcc"
},
{
"label": "Compile CPP File",
"type": "shell",
"command": "g++ -o ${fileBasenameNoExtension} ${file}",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$gcc"
}
]
}
```
4. 然后,您可以在VSCode的终端中执行这些任务,以编译并运行您的 .c 和 .cpp 文件。
希望这可以帮助您!
阅读全文
相关推荐

















