【发布时间】:2011-07-15 08:12:51
【问题描述】:
我知道 #define 在编译为实际值之前被替换。那么为什么这里的第一个代码编译没有错误,而第二个没有?
第一个;
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("bc");
return 0;
}
第二个(不工作);
#include <stdio.h>
#include <stdlib.h>
#define Str "bc";
int main()
{
printf(Str);
return 0;
}
error: expected ')' before ';' token
谢谢你的回答,对不起我的英语不好......
【问题讨论】:
-
你确定第一个正在编译吗?该错误看起来是因为在您的第一个示例中
"bc"之后的;。 -
谢谢你,我的错,我替换了两个代码块
-
谢谢大家,我忘记分号了。
标签: c compiler-errors printf c-preprocessor