我如何在非控制台应用程序中看到cout输出? [英] How can I see cout output in a non-console application?
问题描述
输出到调试窗口似乎很乏味.如果我正在编写非控制台信息,在哪里可以找到 cout
输出?
It seems rather tedious to output to debug window. Where can I find cout
output if I am writing a non-console information ?
赞:
double i = a / b;
cout << b << endl;//I want to check out whether b is zero. It seems the output cannot be found anywhere.
推荐答案
要将字符串输出到调试控制台,请使用 OutputDebugStringA
.请参阅 http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362%28v=vs.85%29.aspx
To output a string to the debug console, use OutputDebugStringA
. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362%28v=vs.85%29.aspx
要使用 std :: ostringstream
将变量值输出到调试控制台,请将字符串发送到 OutputDebugStringA
.
To output variable values to the debug console, using std::ostringstream
, the send the string to OutputDebugStringA
.
过多的输出语句将导致程序严重减速.但是,这是一种很好的技术,可以捕获调试器遇到的问题,例如在使用基本指针时遇到的实际子成员.
Excessive output statements will cause the program to severly slow down. However, it is a good technique to catch things the debugger has a problem with, such as the actual child members when playing with base pointers.
这篇关于我如何在非控制台应用程序中看到cout输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!