views:

90

answers:

4

I'm making an application and would like to test the toString method I just made. I'm using Visual c++ 2008. Is there a way to see console output without having a console window? Such as in the Output panel?

Thanks

+1  A: 

A clean option is to print out to file.

ofstream fout(test.txt);
fout << widget.toString() << endl;
JoshD
+1  A: 

If you call OutputDebugString, it will display the string in the output window when you run the program under VS++. Most other debuggers (and a number of other monitoring applications and such) can/will display such strings as well, but when you run the program without a debugger (or something similar) that output will simply be ignored.

Jerry Coffin
A: 

Add System.Diagnostics and you can use the Debug Classes static methods to write to the output window. ie

  Debug.Write("bleh");
  Debug.WriteLine("bleh");

and whatnot.

Iain
Once again, thanks, but, not .Net
Milo
A: 

If you print to stdout or to stderr for a Windows application, you can still access the output through redirection.

For example:

foo.exe > file.txt

or if you have a Windows version of cat, you can do:

foo.exe | cat
jamesdlin