#include <stdio.h>
#include <cs50.h>
int main(void)
{
int height;
{
printf("Please select a height value between 1-23.");
height = GetInt();
while (height < 1 || height > 23)
{
printf("Height mustbe between 1-23, please choose new value.\n");
height = GetInt();
}
{
for (int n = 0; n < height; n++)
for (int o = 0; o + n + 1 < height; o++)
{
printf(" ");
}
for (int p = 0; p <= o; p++)
{
printf("#");
}
}
}
}
//我不断收到此错误:
使用未声明的标识符“o”。 for (int p = 0; p <= o; p++) ^
我在其上方的行中声明了“0”,我似乎无法弄清楚为什么它会给我这个错误。请帮助,我对 c 非常陌生,非常感谢任何见解。谢谢!
最佳答案
for (int o = 0; o + n + 1 < height; o++)
{
printf(" ");
}
/* o is now out-of-scope */
标识符o
的范围在}
之后停止。
关于c - 使用未声明的标识符 'o',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24997914/