und*_*ack 17 c++ visual-studio-2010
我试过OutputDebugString功能,大多数时候我得到的错误如下:
error C2664: 'OutputDebugStringA' : cannot convert parameter 1 from 'int' to 'LPCSTR'
Run Code Online (Sandbox Code Playgroud)
请建议.谢谢.
pet*_*mcc 24
它只接受字符串作为参数,而不是整数.尝试类似的东西
sprintf(msgbuf, "My variable is %d\n", integerVariable);
OutputDebugString(msgbuf);
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请查看http://www.unixwiz.net/techtips/outputdebugstring.html
Kir*_*sky 11
For debugging purposes you could use _RPT macros.
For instance,
_RPT1( 0, "%d\n", my_int_value );
Run Code Online (Sandbox Code Playgroud)
我所知道的最常见的方式是TRACE宏:
http://msdn.microsoft.com/en-us/library/4wyz8787%28VS.80%29.aspx
例如:
int x = 1;
int y = 16;
float z = 32.0;
TRACE( "This is a TRACE statement\n" );
TRACE( "The value of x is %d\n", x );
TRACE( "x = %d and y = %d\n", x, y );
TRACE( "x = %d and y = %x and z = %f\n", x, y, z );
Run Code Online (Sandbox Code Playgroud)
小智 5
我在搜索错误消息时找到了这个答案:https : //stackoverflow.com/a/29800589
基本上,您只需要在使用时在输出字符串前面放一个“L” OutputDebugString:
OutputDebugString(L"test\n");
Run Code Online (Sandbox Code Playgroud)
它对我很有用。
编辑:
为了用数据格式化字符串,我最终使用了
char buffer[100];
sprintf_s(buffer, "check it out: %s\n", "I can inject things");
OutputDebugStringA(buffer);
Run Code Online (Sandbox Code Playgroud)
我绝不是专家,我只是找到了一些有用的东西并继续前进。