I'm using Visual Studio 2022 Community.
For Some reason, I use OutputDebugString() with very long strings. Sometime, It doesnot works.
What I found.
When string length is larger than 1024 * 32, OutputDebugString() doesnot work.
For such long string to work with OutputDebugString(), I have to add 2 NULL at the end of the string..
Is this intended action??
#include <stdio.h>
#include <windows.h>
#include <tchar.h>
void testOutputDebugging( int sizeBuf ) {
TCHAR *buf = (TCHAR *)calloc( sizeBuf * sizeof( TCHAR ), 1 );
for( int i = 0; i < sizeBuf - 1; i++ )
buf[ i ] = _T( 'A' );
TCHAR buf2[32];
_stprintf_s( buf2, 32, _T( "\nsize=%d\n" ), sizeBuf );
OutputDebugString( buf2 );
OutputDebugString( buf );
OutputDebugString( buf2 );
free( buf );
}
int main() {
testOutputDebugging( 1024 );
testOutputDebugging( 1024 * 16 );
testOutputDebugging( 1024 * 17 );
testOutputDebugging( 1024 * 32 );
return 0;
}
I ran the with VS2022. Result screen shot looks like this..