我試圖運行此代碼,但我不斷收到的:錯誤:使用未聲明的標識符
:21:20: error: use of undeclared identifier 'r'
for(int s = h - r; s > 0;s--)
,但我似乎無法找出原因,我發現了錯誤。有人可以幫我從這裏出去嗎?
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int h;
do
{
printf("please give me a positive int between 1 and 23: ");
h = GetInt();
}
while (h < 1 || h > 23);
//get int and store it
for(int r = 0; r < h; r++)
{
printf("#");
}
for(int s = h - r; s > 0;s--)
{
printf(" ");
}
}
r的範圍僅限於聲明它 –
環路未申報意味着你還沒有宣佈你正在使用它的範圍變量。嘗試使用它們之前聲明變量。 – Lundin