初级链表,麻烦帮我看下问题出在哪
#include<stdio.h>#include<malloc.h>
#include<string.h>
struct List_T
{
int Mun;
struct List_T * pNext;
};
int main()
{
struct List_T * head = NULL;
struct List_T * pOne;
struct List_T * pTwo;
struct List_T * pTem;
head = (struct List_T *)malloc(sizeof(struct List_T));
if (head == NULL)
{
perror("malloc error!");
return 1;
}
memset(head, 0, sizeof(struct List_T));
pOne = (struct List_T *)malloc(sizeof(struct List_T));
if (pOne == NULL)
{
perror("malloc error!");
return 1;
}
memset(pOne, 0, sizeof(struct List_T));
pOne->Mun = 1;
head->pNext = pOne;
pTwo = (struct List_T *)malloc(sizeof(struct List_T));
if (pTwo == NULL)
{
perror("malloc error!");
return 1;
}
memset(pTwo, 0, sizeof(struct List_T));
pTwo->Mun = 2;
pOne->pNext = pTwo;
pTem = head->pNext;
while(pTem != NULL)
{
printf("%d\n",pTem->Mun);
pTem = head->pNext;
}
return 0;
} 为什么我一运行就死循环了 一直111111111111111 麻烦帮我看下问题出在哪,谢谢!