无法弄清楚我在这里做错了什么。任何建议将不胜感激。下面的代码和错误。
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int blocks = 0;
do
{
printf("%dn", blocks);
int blocks = get_int();
}
while (blocks < 0 || blocks > 23);
}
mario.c:10:13:错误:声明隐藏局部变量 [-werror,-wshadow] 整数块 = get_int((; ^
Mario.c:6:9:注意:之前的声明在这里 整数块 = 0; ^
mario.c:10:13:错误:未使用的变量"块"[-werror,-wunused-variable] 整数块 = get_int((; ^
生成 2 个错误。
制造: *** [马里奥] 错误 1
看起来你声明了两次:
int blocks = 0; //<--- First here
int blocks = get_int(); //<--- Then here
尝试将第二行更改为:
blocks = get_int();
我想你必须先说int blocks = get_int()
然后转到
do
{
printf....
}
我的理由是,在您的代码中,您已经int blocks
给出了一个固定整数 0。
现在我也被困在这个问题上