LPWSTR wprintf

因为LPWSTR指向的是一个宽字符串,而printf()是针对通常的字符串(非宽字符串)的,所以两者的类型不匹配,应该使用wprintf()

 

s String When used with printf functions, specifies a single-byte–character string; when used with wprintf functions, specifies a wide-character string. Characters are printed up to the first null character or until the precision value is reached. 
S String When used with printf functions, specifies a wide-character string; when used with wprintf functions, specifies a single-byte–character string. Characters are printed up to the first null character or until the precision value is reached. 

 

#define __T(x) L ## x
...
#define _T(x) __T(x)
#define _TEXT(x) __T(x)
...

MSDN98
mk:@MSITStore:C:\MSDN98\98VS\2052\vclang.chm::/html/_pluslang_c.2b2b_.string_literals.htm

C++ String Literals
A string literal consists of zero or more characters from the source character set surrounded by double quotation marks ("). A string literal represents a sequence of characters that, taken together, form a null-terminated string.

Syntax

string-literal :

"s-char-sequenceopt"
L"s-char-sequenceopt"

...
To specify a string of type wide-character (wchar_t[]), precede the opening double quotation mark with the character L. For example:

wchar_t wszStr[] = L"1a1g";

http://msdn.microsoft.com/en-us/library/ms686944(v=VS.85).aspx

原文链接: https://www.cnblogs.com/diyunpeng/archive/2012/01/17/2324358.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    LPWSTR wprintf

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/40366

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月8日 下午5:03
下一篇 2023年2月8日 下午5:03

相关推荐