#include <cs50.h>
#include <stdio.h>
int main(void)
{
//Prompt user for valid input
int n;
do
{
n = get_int("height: ");
}
while (n < 0 || n > 23);
}
//drawing pyramid
for(int i = 0; i < n; i++)
{
printf(" ")
}
当我输入 make mario 时,我的终端中会发生以下情况...
error: expected identifier or '('
for (int i = 0; i < n; i++)
^
有人知道为什么我的代码中会出现此错误消息吗?为什么会被标记? “for”错误下方的绿色 (^) 箭头是否意味着程序不希望我使用 for 循环?
最佳答案
您使用的是逗号“,”而不是冒号“;”。
在for循环中,使用冒号“;”在单独的声明之间进行划分。
关于c - 为什么我的 for 循环预期显示标识符错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50876814/