Piping input into a c++ program to debug in Visual Studio(将输入管道输入到 C++ 程序中以在 Visual Studio 中进行调试)
问题描述
之前可能有人问过这个问题,但到目前为止我还没有找到任何答案.我正在尝试使用多行输入启动我的程序,即我不想每次都在命令行中输入一些东西(因为我可能会犯错误).我查看了命令行参数并将我的输入粘贴到那里,但它把它解释为每一行都是一个命令.
this has probably been asked before, but I haven't been able to find any answers so far. I'm trying to start my program up with multi-line input, I.E. something I don't want to type in the command line every time (as I'd probably make a mistake). I looked into the command line arguments and I pasted my input in there, but it interpreted it as every line being a command.
输入以防万一:
8
c j i b s x k j
t a o a v y z l
x r t s w o n m
z y x e n s p r
l l o b s t e r
t g x a a a a a
j p e l a k e k
t r s l j e e e
cat
test
baseball
bake
paste
lobster
stake
zen
locks
rake
gel
slack
jar
dinosaur
0
推荐答案
将数据放入文件中,然后转到 Visual Studio 中的项目属性并选择调试"类别.
Put your data in a file then go to the project properties in Visual Studio and select the "Debugging" category.
在命令参数"属性类型中:
In the "Command Arguments" property type:
< "path/to/the/file"
现在,当调试器启动或使用 Ctrl-F5 在 Visual Studio 中(但没有调试器)启动程序时,该文件将通过标准输入提供给程序.
Now that file will be fed to the program via standard input when the debugger is launched or when you launch the program within Visual Studio (but without the debugger) using Ctrl-F5.
如果希望测试文件随项目一起移动,可以使用VS宏来指定项目目录等.
You can use VS macros to specify the project directory, etc. if you want the test file to move along with the project.
这篇关于将输入管道输入到 C++ 程序中以在 Visual Studio 中进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将输入管道输入到 C++ 程序中以在 Visual Studio 中进行调试


基础教程推荐
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01