📄 creat.c
字号:
#include"yy.h"
int n;
NODE *creat(NODE *head)
{
NODE *p1,*p2;
char c;
clrscr();
printf("\n\n\n\tWarning!Creat a new adressbook will loose the old adress book.\n");
printf("\n\t continute?(y/n)\n\t");
c=getch();
if(c=='n'||c=='N')return head;
free_nodes(head);
printf("\n\tpress any key to continute...\n\t");
getch();
clrscr();
n=0;
p2=(NODE *)malloc(LEN);
p1=p2;
printf("\n\n\n\tPlease input the name:\n\t");
gets(p1->name);
printf("\tPlease input the phone number:\n\t");
gets(p1->phone);
printf("\tPlease input the sex:\n\t");
gets(p1->sex);
printf("\tPlease input the age:\n\t");
gets(p1->age);
printf("\tPlease input the birthday:\n\t");
gets(p1->birthday);
printf("\tPlease input the dormitory:\n\t");
gets(p1->dormitory);
head=NULL;
while(1)
{
n+=1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
printf("\n\t continute?(y/n)\n\t");
c=getch();
if(c=='n'||c=='N')break;
p1=(NODE *)malloc(LEN);
printf("\n\t now,please input the %dth adress.\n",n+1);
printf("\tplease input the name:\n\t");
gets(p1->name);
printf("\tplease input the phone number:\n\t");
gets(p1->phone);
printf("\tplease input the sex:\n\t");
gets(p1->sex);
printf("\tplease input the age:\n\t");
gets(p1->age);
printf("\tplease input the birthday:\n\t");
gets(p1->birthday);
printf("\tplease input the dormitory:\n\t");
gets(p1->dormitory);
}
p2->next=NULL;
return head;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -