http://www.nicklib.com/bbs/board.php?bo_table=bbs_util&wr_id=12&sca=Visual+Studio
#ifdef WIN32
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <crtdbg.h>
#endif
void Trace(char* lpszFormat, ...)
{
#ifdef WIN32
char szBuffer1[512];
char* lpBuf;
char* lpsz;
char szBuffer[512];
va_list args;
va_start(args, lpszFormat);
_vsntprintf(szBuffer1, sizeof(szBuffer1)/sizeof(szBuffer1[0]), lpszFormat, args);
va_end(args);
lpsz = szBuffer1;
lpBuf = szBuffer;
while (*lpsz != '\0')
{
if (lpBuf > szBuffer + sizeof(szBuffer)/sizeof(szBuffer[0]) - 3)
{
*lpBuf = '\0';
if ((1 == _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s", szBuffer)))
_CrtDbgBreak();
lpBuf = szBuffer;
}
if (*lpsz == '\n')
*lpBuf++ = '\r';
*lpBuf++ = *lpsz++;
}
*lpBuf = '\0';
if ((1 == _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s", szBuffer)))
_CrtDbgBreak();
#else
return;
#endif
}
'프로그래밍(Programming) > c++, 11, 14 , 17, 20' 카테고리의 다른 글
void* operator new(size_t t, 추가 인자와 사이즈 계산 (0) | 2012.11.01 |
---|---|
Protected 생성자 (0) | 2012.11.01 |
난수 발생 srand, rand (0) | 2012.11.01 |
비트필드(Bit Field) (0) | 2012.11.01 |
_tcstok 사용방법(문자열 분리) (0) | 2012.11.01 |