考试酷解析——C4_Scope of a Variable

解析

第二题:

有没有和外部文件联系不影响输出 scopre rule,可以当作没有extern 变量。

第三题:

extern 后面仍然要接数据类型,所以这题会报错是因为没有声明array 的 type

第四题:

extern 的作用域是从声明到当前文件的末尾,而非这个工程的任何一个文件,extern是表示此变量或函数是在别处定义的。

第五题:

//Comment on the output of this C code?
#include 
int main()
{
int i;
for (i = 0;i < 5; i++)
int a = i;
printf("%d", a);
}

 因为a在for循环内声明,所以作用域仅在for循环内,所以会出现syntax error in declaration of a

 

 

你可能感兴趣的:(C语言考试酷,c语言)