//Massage.h文件
#ifndef __MASSAGELIST_H__
#define __MASSAGELIST_H__#define unit unsigned int
#define PASS 0
#define ERROR -1
#define MALLOC_ERROR -2
#define N 40
typedef int LinkData;
typedef struct node
{
LinkData ID;
char Name [N];
char Mobile_Phone [N];
char Home_Address [N];
char Company_Phone [N];
struct node *next; //节点指针
}Node;
typedef Node *PNode; //重命名节点指针类型
int Time_Display(); //定义时间函数
int Menu(); //显示界面
int Insert_Last(PNode head, LinkData data); //尾插法添加好友
int Get_Information(PNode head) ; //显示好友信息
int Find_Element(PNode head, char *Name); //查找好友
void Delete_Friend(PNode head, char *Name); //删除好友
#endif
//Massage.c文件
#include "Massage.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
int Menu()
{
system ("clear");
printf ("\t************************************************\n");
printf ("\t* *\n");
printf ("\t* wellcome to use Massage list *\n");
printf ("\t* *\n");
printf ("\t* 1 --------> add friend info *\n");
printf ("\t* 2 --------> list friend info *\n");
printf ("\t* 3 --------> search friend info *\n");
printf ("\t* 4 --------> delete friend *\n");
printf ("\t* 5 --------> exit *\n");
printf ("\t* *\n");
printf ("\t* auther:yuhuofei *\n");
printf ("\t************************************************\n");
printf (" \n");
printf("\t");
Time_Display();
printf (" \n");
printf ("\tPlease enter the num to choose function:");
}
// 时间显示函数
int Time_Display()
{
time_t timep;
struct tm *p;
time(&timep); /*获得time_t结构的时间,UTC时间*/
p = localtime(&timep); /*转换为struct tm结构的当地时间*/
printf("Time: %4d/%02d/%02d ", 1900+p->tm_year, 1+p->tm_mon, p->tm_mday);
printf("%02d:%02d:%02d\n", p->tm_hour, p->tm_min, p->tm_sec);
return 0;
}
//添加好友信息
int Insert_Last(PNode head, LinkData data)
{
// 创建新的结点
if(head == NULL)
{
return ERROR;
}
PNode p = (PNode)malloc(sizeof(Node)/sizeof(char));
&n