还有人遇到过这样的问题吗?
swprintf_s(v, len, L"%ws", var);
MessageBox(NULL, v, NULL' NULL);
消息框打印出“%ws”而不是var的内容。
谢谢。
最佳答案
C++Builder 不支持 Visual Studio 支持的所有大小前缀(反之亦然)。在这种情况下,C++Builder 不支持 %s
的 w
前缀,但 Visual Studio 支持。
Visual Studio :
Format Specification Syntax: printf and wprintf Functions
A format specification, which consists of optional and required fields, has the following form:
%[flags] [width] [.precision] [{h | l | ll | w | I | I32 | I64}] type
C++Builder:
Print format specifiers have the following form:
% [flags] [width] [.prec] [F|N|h|l|L] type_char
如果 var
是宽字符串,则可以在两个编译器中使用 %s
或 %ls
。
关于c++ - BCB swprintf 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29130917/