管道输入到一个c ++程序在Visual Studio中调试 [英] Piping input into a c++ program to debug in Visual Studio

查看:203
本文介绍了管道输入到一个c ++程序在Visual Studio中调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是以前被问过,但我迄今还没有找到任何答案。我试图用多行输入启动我的程序,I.E.我不想每次都在命令行中键入内容(因为我可能会犯错误)。我查看了命令行参数,我在那里粘贴我的输入,但它解释为每一行都是一个命令。

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.

在Command Arguments属性类型中:

In the "Command Arguments" property type:

< "path/to/the/file"

现在该文件将通过标准输入当调试器启动时或当您在Visual Studio(但没有调试器)使用Ctrl-F5启动程序。

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中调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆