struct问题
在dev-c++里建了一个工程,有两个.c文件。
//////////test1.c ////////
struct st{
int i;
char *str;
};
struct st *np;
struct st *init(){
if((np=(struct st*)malloc(sizeof(struct st)))==NULL)
return NULL;
np->name=(char *)malloc(12);
strcpy(np->str,"hello");
np->i=12;
return np;
}
///////testmain.c///////////////
struct st *init();
main(){
printf("%s",init()->name);
system("pause");
}
编译报错,dereferencing pointer to incomplete type
请各位大虾指教,怎么改。。谢谢