关于goto语句的用法
程序代码:// gotoIt.c--goto语句的示例
#include <stdio.h>
int main(void)
{
int n;
start:
puts("Enter a number between 0 and 10: ");
scanf("%d", &n);
if (n < 0||n > 10)
goto start;
else if (n == 0)
goto location0;
else if (n == 1)
goto location1;
else
goto location2;
location 0:
puts("You entered 0.\n);
goto end;
location 1:
puts("You entered 1.\n);
goto end;
location 2:
puts("You entered something between2 and 10.\n);
goto end;
end:
return 0;
}
以上是我完全按照书上所讲来写的,可是为什么编译器报了一堆的错误……主要说是location这些标签没有声明
可是书上完全就是这么写的啊。为什么会这样呢?



我刚才绝对在做梦
……脑子简直不清醒了。