【发布时间】:2011-03-01 23:20:30
【问题描述】:
我想为应用程序 ID 使用某种常量(这样我就可以在 printf 中使用它)。
我有这个:
#define _APPID_ "Hello World!"
然后是简单的 printf,将其调用为 %s(字符串)。它把它说出来:
simple.cpp:32: error: cannot convert ‘_IO_FILE*’ to ‘const char*’ for argument ‘1’ to ‘int printf(const char*, ...)’
我将使用什么来定义要在 printf 中使用的应用程序 ID?我试过了:
static const char _APPID_[] = "Hello World"`
但它不起作用,我认为同样的错误。
【问题讨论】:
-
能否请您发布实际的 printf() 行?还要指出你正在使用什么编译器。
-
同样的错误“你认为”?它要么是,要么不是。你编译了代码,而不是我们。如果您不知道自己遇到了什么错误,您希望其他人如何?
-
#define和printf()?你确定这是一个 C++ 问题吗?
标签: c++ string c-preprocessor