c++ - 如何在字符串中使用符号?

标签 c++ c visual-c++ coding-style

这一行不会在 Visual C++ 中编译

printf("x=%"PRIszu")\n",

即使符号已定义:

#define PRIszu    "Iu"

我收到以下错误:

Error C3688 invalid literal suffix 'PRIszu'; literal operator or template 'operator ""PRIszu' not found

那么我该如何修复这个打印行以使用定义的符号呢?

最佳答案

也许……?

printf("x=%" PRIszu "\n", yourVar);

我怀疑您使用的是 C++11 编译器,它允许用户定义的文字。在这里查看答案:Using macro with string fails on VC 2015

关于c++ - 如何在字符串中使用符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29154364/

相关文章:

c - 迭代未知长度的 int 数组

c++ - 如何在VC++中使用.lib、.dll和.exp文件?

c++ - 错误 4 错误 C3861 : 'snprintf' : identifier not found

c++ - 在 C++ 代码中使用 fprintf

c++ - OpenCV 数据矩阵代码查找器

c++ - 是否应该从命名空间库中向前声明类?

c - 无法编译 ecepass.c

c 程序段错误对我来说没有意义(c 初学者)

c++ - boost::variant<T> 到 std::string

c++ - MySQL 连接器/C++