【发布时间】:2013-01-27 05:54:15
【问题描述】:
为什么 for 循环不能由非 int 变量运行?我试图通过使用浮点变量来运行 for 循环,但它不能由除 int 类型之外的任何其他变量运行?
【问题讨论】:
-
显示一些代码,否则您的问题将被关闭。
-
一些代码总是有用的。
-
顺便说一句,一个工作示例:
int main(){ float i = 0.0; for(i=0.0; i<=3; i+=0.5){ printf("%.3f\n",i); } return 0; } -
这篇文章回答了您的问题以及更多其他问题。在提问之前您是否搜索过 SO 网站? What is the full "for" loop syntax in C (and others in case they are compatible)?