我想在完成后暂停控制台c ++程序以观察其结果。我找不到任何属性启动配置来暂停我的程序。这是我在launch.json中的代码。
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) build and launch",
"type": "cppvsdbg",
"request": "launch",
"preLaunchTask": "build",
"program": "${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
}
]
}
谢谢你的帮助。这是我的解决方案:我在命令中运行cmd来运行我的程序,并在完成后暂停
{
"name": "(Window) build and run",
"type": "cppvsdbg",
"request": "launch",
"preLaunchTask": "build",
"program": "cmd",
"args": [
"/k",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"&",
"pause",
"&",
"exit"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
}
system("pause");
//这是我用的
cin.get();
//你可以使用它,但是当你按下ENTER键时,控制台会关闭,如果你输入一个变量它不是一个好的解决方案