求助,关于双链表插入的操作,困扰了我很久
void ListAdd(DLinkList head){
int n;
DLinkList s_ptListP,s_ptListQ;
char s_pTemp,t;
s_ptListP=head->next;
printf("please input the place you want to add:");
scanf("%d",&n);
while(n>1)
{
s_ptListP=s_ptListP->next;
n--;
}
s_ptListQ=(DLinkList)malloc(sizeof(DNode));
printf("please input the content you want to add:");
scanf("%e",&s_pTemp);
t=s_pTemp; // 单步调试时t的值为乱码,s_pTemp不是我输入的值,这是什么原因啊
s_ptListQ->data=s_pTemp;
if(s_ptListP==NULL)
{
s_ptListQ=NULL;
s_ptListP->next=s_ptListQ;
s_ptListQ->prior=s_ptListP;
}
else if(s_ptListP->prior==head)
{
head->next=s_ptListQ;
s_ptListP->prior=s_ptListQ;
s_ptListQ->next=s_ptListP;
}
else
{
s_ptListQ->next=s_ptListP->next;
s_ptListP->next->prior=s_ptListQ;
s_ptListP->next=s_ptListQ;
s_ptListQ->prior=s_ptListP;
}
}