c语言编写通讯录

来源:百度知道 编辑:UC知道 时间:2024/05/25 05:15:45
士大夫士大夫

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE sizeof(NODE)
typedef struct node
{
char name[20];
char phone_num[20];
char add[50];
struct node *next;
}NODE;

NODE * creat_list()
{
NODE * h,* p1,*p2;
int i=1;
h=(NODE*)malloc(SIZE);
printf("请输入姓名:");
scanf("%s",h->name);
printf("\n请输入电话号码:");
scanf("%s",h->phone_num);
printf("\n请输入地址:");
scanf("%s",h->add);
p1=p2=h;
while(1)
{
printf("是否继续添加?输入1继续,0 结束");
scanf("%d",i);
if(0==i) break;
p1 =(NODE*)malloc(SIZE);
printf("\n请输入姓名:");
scanf("%s",p1->name);
printf("\n请输入电话号码:");
scanf("%s",p1->phone_num);
printf("\n请输入地址:");
scanf(&qu