Reputation:
I tried going to project properties, selected debugging under configuration properties, and set command arguments to "> out.txt" (without quotation marks of course). However, when I run the program (with F5) I still see output on the console, and no out.txt file is created. This is just a simple C++ Hello World program. These steps worked for my friend but not for me (he's using VS2008 also). I've heard of disabling the hosting process but it seems that's just for Visual Studio 2005.
It appears that "> out.txt" is being passed in as an argument. argc is 3, argv[1] is ">", and argv[2] is "out.txt". Is this not supposed to happen? What can I do to fix it?
Upvotes: 3
Views: 3297
Reputation: 347556
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.
To fix, you can install VS2008 SP1 or use this work around.
Here is the work around:
Upvotes: 1
Reputation: 16953
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. You can download SP1 here.
Upvotes: 4
Reputation: 3335
Works perfectly for me in vs 2005. Maybe check the arguments in main() to see if "> out.txt" is passed in as argument instead of being evaluated at the level of cmd.exe
Upvotes: 0