输出链表问题
#include <stdio.h>
#include <stdlib.h>
struct Clerk
{
char cName[20];
int iNumber;
struct Clerk* pNext;
};
int iCount;
struct Clerk* Create()
{
struct Clerk* pHead=NULL;
struct Clerk* pEnd,*pNew;
iCount=0;
pEnd=pNew=(struct Clerk*)malloc(sizeof(struct Clerk));
printf("Please first enter Name ,then Number\n");
scanf("%s",&pNew->cName);
scanf("%s",&pNew->iNumber);
while(pNew->iNumber!=0)
{
iCount++;
if(iCount==1)
{
pNew->pNext=pHead;
pEnd=pNew;
pHead=pNew;
}
else
{
pNew->pNext=NULL;
pEnd->pNext=pNew;
pEnd=pNew;
}
pNew=(struct Clerk*)malloc(sizeof(struct Clerk));
scanf("%s",&pNew->cName);
scanf("%s",&pNew->iNumber);
}
free(pNew);
return pHead;
}
void Print(struct Clerk* pHead)
{
struct Clerk *pTemp;
int iIndex=1;
printf("----The List has %d members:---\n",iCount);
printf("\n");
pTemp=pHead;
while(pTemp!=NULL)
{
printf("The NO%d member is:\n",iIndex);
printf("The name is :\n",pTemp->cName);
printf("The number is :%d\n",pTemp->iNumber);
printf("\n");
pTemp=pTemp->pNext;
iIndex++;
}
}
int main()
{
struct Clerk * pHead;
pHead=Create();
Print(pHead);
return 0;
}
用的是dev-c++
不知道问题在哪,求指教。刚接触链表,只能看懂大概。就是cmd调出以后,不管怎么输入,都结束不了,就一直输入