#include<stdlio.h>
#include<stdlib.h>
typedef?struct?student
{
char?name[20];
int?age;
struct?student?*next;
}stu;
int?main()
{
struct?student?*phead,*pnew,*ptail;
pnew=(struct?student*)malloc(sizeof(stu));
ptail=pnew;
phead=pnew;
return?0;
}
1 回答

onemoo
TA貢獻(xiàn)883條經(jīng)驗(yàn) 獲得超454個(gè)贊
第12 13 14行: phead, pnew, ptail 這三個(gè)指針都是指向同一個(gè)stu的了。
而且最后你申請(qǐng)出來的內(nèi)存沒有free掉。
第1行: stdio.h 拼錯(cuò)了
你打算做的鏈表結(jié)構(gòu)是什么?
- 1 回答
- 0 關(guān)注
- 1305 瀏覽
添加回答
舉報(bào)
0/150
提交
取消