How can I output when debugging in Visual Studio 2008?

I tried to go to the project properties selected by debugging in the configuration properties and set the arguments to the "> out.txt" command (without quotes, of course). However, when I run the program (with F5), I still see the output on the console and the out.txt file is not created. It is just a C ++ Hello World program. These steps worked for my friend, but not for me (he also used VS2008). I heard about disabling the hosting process, but it seems to be for Visual Studio 2005.

It seems that "> out.txt" is being passed as an argument. argc is 3, argv [1] is ">", and argv [2] is "out.txt". Shouldn't this happen? What can I do to fix this?

+3
source share
3 answers

According to this error report on the Microsoft Connect website, this problem has been fixed in Visual Studio 2008 Service Pack 1 (SP1). I am running VS2008 SP1 on my system, and output redirection works fine for me. You can download SP1 here .

+4
source

I have the same results as you: redirecting in 2008 does not work for me either, but it works in 2005. As @ChrisN mentioned, this is a bug with VS 2008, and it was fixed in VS 2008 SP1.

To fix this, you can install VS2008 SP1 or use this work.

Here is the work around:

  • Redirect output to code via freopen, this link explains how
  • Wrap this code in #ifdef REDIRECT_OUTPUT_TO_FILE and #endif
  • Go to the C / C ++ tab, then the preprocessor tab and set REDIRECT_OUTPUT_TO_FILE
+1
source

Works fine for me in vs 2005. Perhaps check the arguments in main () to see if "> out.txt" is passed as an argument and not evaluated at cmd.exe level

0
source

Source: https://habr.com/ru/post/1389875/


All Articles