/// extern array variable
extern int array[];
printf(sizeof(array) );
/// the result is 4-- the pointer's size
/// only when array is defined in current file
int local_array[10] = {0};
printf(sizeof(local_array));
//the result is 4*10 = 40 ///
本文探讨了extern关键字声明变量及数组与sizeof运算符的使用方法。通过示例代码展示了extern声明的数组与局部数组在不同上下文中的大小计算区别。
/// extern array variable
extern int array[];
printf(sizeof(array) );
/// the result is 4-- the pointer's size
/// only when array is defined in current file
int local_array[10] = {0};
printf(sizeof(local_array));
//the result is 4*10 = 40 ///
2113

被折叠的 条评论
为什么被折叠?
