c++ - BCB swprintf 不工作

标签 c++ c c++builder

还有人遇到过这样的问题吗?

swprintf_s(v, len, L"%ws", var);
MessageBox(NULL, v, NULL' NULL);

消息框打印出“%ws”而不是var的内容。

谢谢。

最佳答案

C++Builder 不支持 Visual Studio 支持的所有大小前缀(反之亦然)。在这种情况下,C++Builder 不支持 %sw 前缀,但 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:

printf Format Specifiers

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/

相关文章:

c++ - 使用友元类的单例实现(C++)

c++ - 没有电话接线员

c - C代码每次读取一定数量的文件后退出

c++ - 当使用__block时,clang BlocksRuntime在可执行文件中嵌入 'obsolete compiler'警告

c++ - Direct2D 仅在 C++ Builder 中部分链接

c++ - 是否可以创建一个带有索引但没有指针的单链表?

c++ - 如何有效地使用 QCustomPlot 绘制大型时间序列?

c - 排序结构记录

ssl - 如何使用 Embarcadero FireDAC 在 AWS RDS 上托管的 MariaDB 上设置 SSL

C++ Builder 将 TMemoryStream 缓冲区读取为无效指针