C++ 使用vs代码调试文件时,如何将文件传递到程序中
我想启动一个.exe(一个编译过的cpp程序),并将一个文件传递给它。在CMD上,我会像C++ 使用vs代码调试文件时,如何将文件传递到程序中,c++,windows,debugging,visual-studio-code,exe,C++,Windows,Debugging,Visual Studio Code,Exe,我想启动一个.exe(一个编译过的cpp程序),并将一个文件传递给它。在CMD上,我会像a.exe
a.exe
那样执行。如何在调试模式下使用VS代码启动它
这是我的launch.json文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.exe",
"args": [
"<",
"input.txt"
],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
}
]}
{
“版本”:“0.2.0”,
“配置”:[
{
“名称”:“C++启动”,
“类型”:“cppdbg”,
“请求”:“启动”,
“程序”:“${workspaceRoot}/a.exe”,
“args”:[
“您缺少的是告诉gdb文件的实际位置。在尝试提供输入文件时,您需要将文件的位置放在引号中,因此它看起来像这样:
{
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [
"<", "${fileDirname}/words5.txt"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
{
“版本”:“0.2.0”,
“配置”:[
{
“名称”:“g++-生成和调试活动文件”,
“类型”:“cppdbg”,
“请求”:“启动”,
“程序”:“${fileDirname}/${fileBasenameNoExtension}”,
“args”:[
“如果你给我a-1,你能给我一个答案吗?你找到解决办法了吗?我也陷入了同样的困境。