for(int i = 0;i<10;i++)这样写循环时可能会出现如题编译错误,解决方法有两种,如下:
1 将文件后缀名由".c"改为".cpp"
2 int i;
for(i=0;i<10;i++)
英文解释:原文
It's an error message about some code that you failed to show us. In
general, you can't expect us to know what the problem is unless you
show us the actual code as well as the error message.
In this case, you've lucked out. You probably have something like this:
...
for (int i = 0; i < N; i ++) {
...
}
...
which declares the loop variable as part of the for loop itself. This
feature was added to the language with the C99 standard; it's not
supported in C90.
You can either use C99 mode (but beware: gcc doesn't fully support
C99; see <), or you can re-write
the code to be compatible with C90:
...
int i;
...
for (i = 0; i < N; i ++) {
...
}
...
which is legal C99 as well.
--
Keith Thompson (The_Other_Keith) <~kst>
San Diego Supercomputer Center <* <~kst>
We must do something. This is something. Therefore, we must do this.
阅读(3182) | 评论(0) | 转发(0) |