VS code C++ 程序调试重定向

linux下的重定向符号

输入重定向到文件

1
program < file

输出重定向到文件

1
program > file

VSC设置launch.json

无论是直接在program直接写重定向符还是参数里写,都无效

1
2
3
{
"args": ["<", "input.txt"]
}

正确的打开方式

1
2
3
4
5
6
7
{
"setupCommands": [
{
"text": "settings set target.input-path ${workspaceFolder}/input"
}
]
}

以上的命令其实就是在lldb启动时执行的lldb命令,将input文件重定向到程序中。