相关疑难解决方法(0)

C:for循环初始化声明

有人可以详细说明以下gcc错误吗?

$ gcc -o Ctutorial/temptable.out temptable.c 
temptable.c: In function ‘main’:
temptable.c:5: error: ‘for’ loop initial declaration used outside C99 mode
Run Code Online (Sandbox Code Playgroud)

temptable.c:

...
/* print Fahrenheit-Celsius Table */
main()
{
    for(int i = 0; i <= 300; i += 20)
    {
        printf("F=%d C=%d\n",i, (i-32) / 9);        
    }
}
Run Code Online (Sandbox Code Playgroud)

PS:我含糊地回忆起int i应该在for循环之前声明.我应该声明我正在寻找一个给出C标准历史背景的答案.

c gcc for-loop syntax-error

43
推荐指数
2
解决办法
6万
查看次数

标签 统计

c ×1

for-loop ×1

gcc ×1

syntax-error ×1