請教
file1.c中(和file2.c在同个工程下)
void ttt();
p(){
int k;
.........
extern *sc;
void ttt();//能成功调用
for(k=0;k <10;k++)
{
printf( "%d ",*(sc+k));//问题所在,不能成功显示所有值,前几个对的,后面是乱码
}
}
/////////////////////////////////////////
file2.c大概程序如下
unsigned char *sc;
void ttt()
{
FILE*fp;
fp=fopen(....)//成功执行
....
sc=(unsinged char*)malloc(100);
freed(sc,1,100,fp)
for(...)
printf( " %d ",*(sc+k));//在file1中调用后,能成功显示出*(sc+k)所有值
....
}
请问,为什么file1中的p()函数不能成功显示*(sc+k)的值
多谢了
[解决办法]
//file2.c
unsigned char *sc;
//file1.c
extern unsigned char *sc; //与file2.c的类型写一样看行不?