Home >Database >Mysql Tutorial >Windows日志打印API的封装使用OutputDebugStringA_MySQL

Windows日志打印API的封装使用OutputDebugStringA_MySQL

WBOY
WBOYOriginal
2016-06-01 13:12:331633browse

在C++编程中,经常会需要打印日志使用dbgview查看相应的一些信息,常用的是这样的:


void __cdecl DbgPrintW(const char *format, ...){	char buf[4096], *p = buf;	va_list args;	va_start(args, format);	p += _vsnprintf(p, sizeof buf - 1, format, args);	va_end(args);	OutputDebugStringW((LPCWSTR)buf);}void __cdecl DbgPrintA(const char *format, ...){	char buf[4096], *p = buf;	va_list args;	va_start(args, format);	p += _vsnprintf(p, sizeof buf - 1, format, args);	va_end(args);	OutputDebugStringA(buf);}

上边是Unicode编码的,下边是普通单字节编码的,

调用很简单:

DbgPrintA("c_name = %s",c_name);



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn