注册 登录
编程论坛 C++教室

为什么会报错“error C2143: syntax error : missing ']' before ';'”

豆饼洋 发布于 2012-09-30 21:28, 640 次点击
错误出现在“double T[n];”这一行,为什么会提示“error C2143: syntax error : missing ']' before ';'”这个错误
double cp[1],k[1];
#define e 7800;
#define h 250;
#define B 0.25;
#define n 20;
double T[n];
    double a[n];
    double b[n];
    double c[n];
    double f[n];

我正在网上看到了类似的程序,为什么这个又没报错呢?

#define LEN 1    //平板长度
#define IMAX 10  
#define H 250   //对流传热系数
#define K 36     //导热系数
#define P 1000  //密度
#define C 4200   //比热容
#define Tf 90    //左端流体温度,设右端温度衡为50度。
double u[IMAX+1];
    double a_array[IMAX+1];
    double d_array[IMAX+1];
    double b_array[IMAX+1];
    double c_array[IMAX+1];
4 回复
#2
豆饼洋2012-09-30 21:32
类似的程序咋就结果不同呢?
#3
有容就大2012-10-01 00:11
#define xx, oo后面有分号?
#4
pangding2012-10-01 10:04
一个有分号,一个没分号,多明显的区别呀。楼主要仔细些。

预处理指令不是 c 语句,因此不以分号结尾。(它们是以换行符结尾的)
#5
hanyueguxing2012-10-02 00:23
定义宏后面去掉;
1