开发者

Seeing console output without console?

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

Thanks


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.


A clean option is to print out to file.

ofstream fout(test.txt);
fout << widget.toString() << endl;


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜