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

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

WBOY
Release: 2016-06-01 13:12:33
Original
1634 people have browsed it

在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);}
Copy after login

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

调用很简单:

DbgPrintA("c_name = %s",c_name);
Copy after login



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template