c语言中出现这个问题是怎么回事?

来源:百度知道 编辑:UC知道 时间:2024/05/24 07:33:40
编程如下程序时
#include<stdio.h>
void main()
{ #define x 12;
printf("%d",&x);
}

出现了这个错是怎么回事?
C:\Documents and Settings\Administrator\桌面\11.cpp(3) : error C2014: preprocessor command must start as first nonwhite space
要怎么改?

预定义语句可以随便放,但你不能放在main函数内吧,而且它不能带分号的,因为它不是C语句

就是说“#define x 12;”这句话必须放在程序的开头的空白地方

在#define中,标准只定义了#。#用来把参数转换成字符串

#include <stdio.h>
#define paster( n ) printf( "token " #n" = %d\n ", token##n )
int main()
{
int token9=10;
paster(9);
return 0;
}
输出为
[leshy@leshy src]$ ./a.out
token 9 = 10