链表节点插入
编译后提示下方注释出:可能使用了未初始化本地变量指针pt,但是在while循环中不是有定义吗?要如何让修改?
#include<stdio.h>
struct employee
{
int no;
char name[20];
struct employee *next;
};
struct employee *insert(struct employee *head, struct employee *pb)
{
struct employee *pn, *pt;
pn = head;
if (pn == NULL)
{
head = pb;
pb->next = NULL;
}
else
{
while ((pn->no != pb->no)&&(pb->next != NULL))
{
pt = pn;
pn = pn->next;
}
if (pn->no == pb->no)
{
if (head == pn)
head = pb;
else
pt->next = pb; //???????
pb->next = pn;
}
else
{
pn->next = pb;
pb->next = NULL;
}
}
return head;