|
发表于 2014-9-16 13:10:47
|
显示全部楼层
:这用dev的mingw编译是可以通过的,而且不给警告。从语句上单独来看,定义了一个a的数组,为全局变量,又在main里malloc了a,于是在main里找不到数组a了,似乎是被覆盖了。
比如在main里输出a[1][1],会报错的, printf("%d\n",a[1][1]);会 subscripted value is neither array nor pointer,编译器全当这个数组不存在一样。
#include <stdio.h>
typedef char * Charpointer;
void s(Charpointer temp);
char a[4][5] =
{
11,12,13,14,15,
21,22,23,24,25,
31,32,33,34,35,
41,42,43,44,45,
};
int main() {
Charpointer a="sfs";
a = (char *)malloc(sizeof(char));;
s(a);
printf("%d\n",*a);
while(1);
}
void s(Charpointer temp) {
*temp=99;
} |
|