问题描述
输出到调试窗口似乎相当冗长乏味。如果我正在写一个非控制台信息,在哪里可以找到 cout
输出?
It seems rather tedious to output to debug window. Where can I find cout
output if I am writing a non-console information ?
Like:
double i = a / b;
cout << b << endl;//I want to check out whether b is zero. It seems the output cannot be found anywhere.
推荐答案
要将字符串输出到调试控制台, code> OutputDebugStringA 。请参见
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.
这篇关于Visual Studio - 如何在非控制台应用程序中查看cout输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!