为什么只能输入一组数据

为什么只能输入一组数据?
p:模拟手机通讯录管理系统,实现对通讯录进行管理。需要对联系人姓名、电话进行管理,利用结构体变量记录联系人的姓名、电话,建立单向链表来存放联系人的信息。
要求实现如下功能:
(1) 写函数create()实现建立单链表来存放联系人的信息,如果输入大写‘Y’字符则继续创建结点存储联系人信息,否则按任意键结束输入。
(2) 写自定义函数输出链表中联系人信息。
(3) 写自定义函数查询联系人的信息。
(4) 写自定义函数释放链表所占内存。
(在主函数依次调用各函数即可)
结构体类型定义如下:

struct friends
{

  char name[20];
    char phone[12]; 
struct friends*next; 
};


#include
#include 

struct friends
{

  char name[20];
    char phone[12]; 
struct friends*next; 
};

struct friends*create()
{

struct friends*pHead=NULL,*pNew=NULL,*pTail=NULL;
int i=0;
char a;
for(i=0;i<100;i++) 
{   
    printf("请依次输入每个联系人姓名,电话:");
    pNew=(struct friends*)malloc(sizeof(struct friends*));
    gets(pNew->name);
    gets(pNew->phone);
    if(pHead==NULL) 
        pHead=pNew;
    else
        pTail->next=pNew;
    pTail=pNew;
    pNew->next=NULL;
    printf("是否继续输入,按Y/y键继续输入,其他键就结束.\n");   
    a=getchar();
    g
    if(a!='Y'&&a!='y') break;
}
return pHead;   
}

int main()
{

struct friends *p;
p=create();
while(p!=NULL)
{
    printf("%c %c",p->name,p->phone);
    p=p->next;
}
return 0;   
}

因为a=getchar();接收到的是换行符,它不是y于是break了
要么你还用gets方法来接收y,这样会自动跳过换行(但相应的y要是字符串而不能是字符类型)
要么你先getchar接收多余的换行,再执行a=getchar();


pNew=(struct friends*)malloc(sizeof(struct friends));