当我在 VS 代码上尝试一个非常简单的 C++ 代码时:
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"Please input: "<<endl;
cin>>a;
cout<<a<<endl;
system("pause");
return 0;
}
下面是我的配置文件:
// tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"${file}",
"-o",
"${fileDirname}\\bin\\${fileBasenameNoExtension}.exe",
"-g",
//"-Wall",
//"-static-libgcc",
// "-fexec-charset=GBK",
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new"
},
"problemMatcher": "$gcc"
},
{
"label": "run",
"type": "shell",
"dependsOn": "build",
"command": "${fileDirname}\\bin\\${fileBasenameNoExtension}.exe",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "new"
}
}
]
}
// launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\bin\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"internalConsoleOptions": "neverOpen",
"MIMode": "gdb",
"miDebuggerPath": "D:\\Program Files\\mingw-w64\\bin\\gdb.exe",
"preLaunchTask": "build"
}]
}
// setting.json
{
"files.associations": {
"iostream": "cpp",
"map": "cpp",
"istream": "cpp",
"*.tcc": "cpp",
"deque": "cpp",
"list": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"ostream": "cpp"
},
"cmake.configureOnOpen": false
}
如果有人能帮助我,我将不胜感激!