2013年1月16日 星期三

Output Debug String

As we know, we can use API OutputDebugString to show string on output window, like,

OutputDebugString(" This is debug message. ");
OutputDebugStringW(L" This is debug message. ");

You also can attach some variable to the output string.

wchar_t* world = L"world";
wchar_t* szBuffer = new wchar_t[512];
wsprintf(szBuffer, _T(" Hello %s \n"),  world);
OutputDebugString(szBuffer);
delete[] szBuffer;

or

wchar_t* message = L"world !";

wchar_t* str = L" Hello ";
wchar_t* buffer = new wchar_t[sizeof(str)+sizeof(message)+1];
wcscpy(buffer, str);
wcscat(buffer, message);
OutputDebugStringW(buffer);


or

float value = 100;
wchar_t* szBuffer = new wchar_t[512];
wsprintf(szBuffer, L" My math grade is %d \n",   (int)value);
OutputDebugString(szBuffer);
delete[] szBuffer;

or

float value = 100;
char* szBuffer = new char[512];
sprintf(szBuffer, L" My math grade is %f \n",  value);
OutputDebugStringA(szBuffer);
delete[] szBuffer;




2013年1月15日 星期二

[Platform Builder] Output Logging Message to File

As we all know, there are lots of useful message shown in output window.
The window doesn't has huge buffer to keep all of messages.













We can try to output it to file and check it later.
Click Target->Debug Message Options->Check Send to file and specify file path