91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

功能:添加,刪除,查找,全部輸出。 添加時自動保存到文件, 查找、全部輸出時從文件中讀取; 復制粘貼即可運行!絕對好用

資源截圖

代碼片段和文件信息

#include
#include
#include
struct?inf
{
char?num[20];
char?name[12];
char?tel[20];
struct?inf?*next;
};
int?count()
{
FILE?*fp;
int?nx;
????fp=fopen(“通訊錄.txt““r“);
fseek(fp?0L?SEEK_END);
????n?=?ftell(fp);//n是文件的字節總數
fseek(fp?0L?SEEK_SET);
x=n/56;
return?x;
}
int?select()/*******************************選擇***************************************/
{
int?num;
printf(“\n請選擇\n“);
scanf(“%d“&num);
printf(“\n“);
return?num;
}
struct?inf?*create()/*******************************創建***************************************/
{
struct?inf?*head*temp*tail;
temp=(struct?inf*)malloc(sizeof(struct?inf));
temp->next=0;
head=tail=temp;
return?head;
}
void?add(struct?inf?*headstruct?inf?*p)?/*******************************添加***************************************/
{
struct?inf?*p1*p2;
p1=head;
p2=p1->next;
while(p2!=0&&p2->numnum)
{
p1=p2;
p2=p2->next?;
}
p1->next=p;
p->next=p2;
}
struct?inf?*find(struct?inf?*head)/*******************************查找***************************************/
{
struct?inf?*p1;
FILE?*fp;
char?n[12];
int?ix;
fp=fopen(“通訊錄.txt““r“);
x=count();
printf(“輸入姓名:\n“);
scanf(“%s“&n);
for(i=0;i {
p1=(struct?inf*)malloc(sizeof(struct?inf));
fseek(fpi*sizeof(struct?inf)0);
fread(p1sizeof(struct?inf)1fp);
if(strcmp(p1->namen)==0)
{
return?p1;
}
}
if(i==x)
{
return?0;
}
}
void?print(struct?inf?*p)/*******************************單個輸出***************************************/
{
printf(“%s:\t姓名:%s\t電話:%s\n\n“p->nump->name?p->tel);
}
void?printall(struct?inf?*head)/*******************************全部輸出***************************************/
{
struct?inf?*p;
p=head->next;
while(p!=NULL)
{
printf(“%s:\t姓名:%s\t電話:%s\n“p->nump->namep->tel);
p=p->next;
}
}
void?del(struct?inf?*head)/*******************************刪除***************************************/
{
struct?inf?*p1*p;
FILE?*fp;
char?n[12]d;
int?ix;
fp=fopen(“通訊錄.txt““r“);
x=count();
printf(“輸入姓名:\n“);
scanf(“%s“&n);
for(i=0;i {
p1=(struct?inf*)malloc(sizeof(struct?inf));
fseek(fpi*sizeof(struct?inf)0);
fread(p1sizeof(struct?inf)1fp);
if(strcmp(p1->namen)==0)
{
break;
}
}
if(i==x)
{
printf(“未找到!\n\n“);
}
else
{
if(i!=-1)
{
printf(“真的要刪除嗎?(Y/N)\n“);
getchar();
scanf(“%c“&d);
if(d==‘Y‘||d==‘y‘)
{
p=(struct?inf*)malloc((x-1)*sizeof(struct?inf));
fseek(fp0L0);
fread(psizeof(struct?inf)ifp);
fseek(fp(i+1)*sizeof(struct?inf)0);
fread(psizeof(struct?inf)x-i-1

評論

共有 條評論