这个主函数怎么写啊?
我有两个构造体:
typedef struct mng {
int nodecnt; /* 链表的长度*/
LTBL *top; /* 指向链表头的指针 */
} MNG;
typedef struct ltbl {
struct ltbl *fp; /* 指向链表中前一个元素的指针*/
struct ltbl *np; /* 指向链表中后一个元素的指针*/
int key; /* KEYWORD */
unsigned char dummy[32]; /* 备用*/
} LTBL;
还有几个函数:int TBLcreate (MNG*mng,int n){...}
void print(MNG *mng){...}
我的主函数:void main()
{
struct mng *p1;
printf( "input record!\n ");
p1 = TBLcreate(p1,10);
print(p1);
}
但是出现了警告: warning C4047: '= ' : 'struct mng * ' differs in levels of indirection from 'int '
和 warning C4700: local variable 'p1 ' used without having been initialized
小弟是菜鸟,
该怎么改阿?!!!
[解决办法]
void main()
{
struct mng *p1=(struct mng *)malloc(sizeof(struct mng)); //初始化
printf( "input record!\n ");
TBLcreate(p1,10); //不要返回值了 ....
print(p1);
}