Chinaunix首页 | 论坛 | 博客
  • 博客访问: 691443
  • 博文数量: 109
  • 博客积分: 2033
  • 博客等级: 大尉
  • 技术积分: 1454
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-11 13:26
文章分类

全部博文(109)

文章存档

2012年(5)

2011年(104)

分类: C/C++

2011-03-26 09:36:16

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.
阅读(3167) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~