变量声明位置不同,但作用域一样,为什么VC编译结果不一样
#include <stdio.h>int main()
{
int index=0;
char* pA[7]={"Sunday","Monday","Tuesday","Wednsday","Thursday","Friday","Saturday"};
printf("今天是一周的第几天?\n");
//int index=0;
scanf("%d",&index);
printf("今天是%s",pA[index]);
return 0;
}
上面代码,如果我把index定义在注释的那里,编译就会报错,提示'index' : undeclared identifier
哪位大神能帮忙说明下么?