[英]How do I pipe output when debugging in Visual Studio 2008?
I tried going to project properties, selected debugging under configuration properties, and set command arguments to "> out.txt" (without quotation marks of course). 我尝试了项目属性,在配置属性下选择调试,并将命令参数设置为“> out.txt”(当然没有引号)。 However, when I run the program (with F5) I still see output on the console, and no out.txt file is created. 但是,当我运行程序(使用F5)时,我仍然在控制台上看到输出,并且没有创建out.txt文件。 This is just a simple C++ Hello World program. 这只是一个简单的C ++ Hello World程序。 These steps worked for my friend but not for me (he's using VS2008 also). 这些步骤适用于我的朋友但不适合我(他也使用VS2008)。 I've heard of disabling the hosting process but it seems that's just for Visual Studio 2005. 我听说过禁用托管过程,但似乎只适用于Visual Studio 2005。
It appears that "> out.txt" is being passed in as an argument. 似乎“> out.txt”作为参数传递。 argc is 3, argv[1] is ">", and argv[2] is "out.txt". argc为3,argv [1]为“>”,argv [2]为“out.txt”。 Is this not supposed to happen? 这不应该发生吗? What can I do to fix it? 我该怎么办才能修复它?
According to this bug report on the Microsoft Connect website, this issue was fixed in Visual Studio 2008 Service Pack 1. I'm running VS2008 SP1 on my system, and output redirection works OK for me. 根据Microsoft Connect网站上的此错误报告 ,此问题已在Visual Studio 2008 Service Pack 1中得到修复。我在我的系统上运行VS2008 SP1,输出重定向对我来说正常。 You can download SP1 here . 你可以在这里下载SP1。
I have the same results as you: The redirection doesn't work in 2008 for me either, but does work in 2005. As @ChrisN mentioned, this is a bug with VS 2008 and it was fixed in VS 2008 SP1. 我有与你相同的结果:重定向在2008年对我来说也不起作用,但在2005年有效。正如@ChrisN所提到的,这是VS 2008的一个错误,它在VS 2008 SP1中得到修复。
To fix, you can install VS2008 SP1 or use this work around. 要修复,您可以安装VS2008 SP1或使用此工作。
Here is the work around: 以下是解决方法:
在vs 2005中对我来说非常适合。也许检查main()中的参数,看看是否将“> out.txt”作为参数传入,而不是在cmd.exe级别进行评估
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.