third commit

master
unknown 6 years ago
parent 50c5165f7b
commit 601711b4e6

31
1.c

@ -1,31 +0,0 @@
void add()
{
int i,m=0;
char n;
char ch[2];
FILE *fp;
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
exit(0);
}
fseek(fp,0L,2);
printf("请输入单词: \n");
scanf("%s",inf[m].word);
printf("请输入释义:\n");
scanf("%s",inf[m].mean);
if(fwrite(&inf[m],LEN,1,fp)!=1)
{
printf("不能保存");
getchar();
}
else
{
printf("已保存\n是否继续添加?");
scanf("%c",&n);
if(n=='Y'||n=='y')
add();
m++;
}
fclose(fp);
}

@ -1,45 +0,0 @@
#include<stdio.h>
struct dic_info
{
char English[40];
char Chinese[100];
}word;
void enter()
{
}
void add()
{
}
void Delete()
{
}
void Edit()
{
}
int main(void)
{
int choice;
do
{
printf("\n\t ==============================");
printf("\n\t *欢迎使用有限规模电子英汉词典*");
printf("\n\t ==============================\n");
printf("\n\t ***********菜单显示***********\n");
printf("\n\t ********【1】词条查找*********\n");
printf("\n\t ********【2】词条增词*********\n");
printf("\n\t ********【3】词条删除*********\n");
printf("\n\t ********【4】词条修改*********\n");
printf("\n\t ********【0】退出词典*********\n");
printf("请选择你要进行的功能:");
scanf("%d",&choice);
switch(choice)
{
case 1:enter();break;
case 2:add();break;
case 3:Delete();break;
case 4:Edit();break;
}
}
while(choice!=0);
return 0;
}

Binary file not shown.

@ -1,4 +1,7 @@
#include <stdio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define LEN sizeof(struct dic_info)
struct dic_info
{
char English[40];
@ -11,48 +14,39 @@ void enter()
void add()
{
}
void Delete()
void Edit()
{
}
void Edit()
void Delete()
{
int a;
int i;
int m;
char a;
char n[40];
printf("请输入要修改的单词:");
while(1)
printf("请输入你要删除的单词:\n");
while(1)
{
scanf("%s",n);
for(i=0;i<400;i++)
{
if(strcmp(n,inf[i].English)==0)
for(m=0;m<400;m++)
{
printf("请输入要修改的内容:\n");
do
if(strcmp(n,inf[m].English)==0)
{
printf("1.修改单词\n");
printf("2.修改释义\n");
printf("0.放弃修改\n");
scanf("%d",&a) ;
switch(a)
{
case 1:printf("请输入修改后的单词:");scanf("%s",&inf[i].English);break;
case 2:printf("请输入修改后的释义:");scanf("%s",&inf[i].Chinese);break;
}
}while(a!=0);
}
inf[m].English=='\0';
inf[m].Chinese=='\0';
printf("删除成功!\n");
return;
}
}
printf("无此单词\n") ;
printf("无此单词\n");
printf("输入y或Y继续操作输入其他返回菜单\n");
scanf("%c",&a);
if(a=='y'||a=='Y')
{
Edit();
Delete();
}
break;
}
}
}
int main(void)
int main(void)
{
int choice,i,n=1;
char a,b;
@ -73,17 +67,16 @@ switch(choice)
{
case 1:enter();break;
case 2:add();break;
case 3:Delete();break;
case 4:Edit();
scanf("%c",&a);
case 3:Delete();
for(i=0;i<n;i++)
scanf("%c",&a);
if(a=='y'||a=='Y')
{
Edit();
Delete();
n++;
}
break;
}
};break;
case 4:Edit();break;
}
}
while(choice!=0);
return 0;

@ -1,28 +0,0 @@
void add()
{
int i,m=0;
char n;
char ch[2];
FILE *fp;
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
exit(0);
}
fseek(fp,0L,2);
printf("请输入单词: \n");
scanf("%s",inf[m].word);
printf("请输入释义:\n");
scanf("%s",inf[m].mean);
if(fwrite(&inf[m],LEN,1,fp)!=1)
{
printf("不能保存");
getchar();
}
else
{
printf("已保存");
m++;
}
fclose(fp);
}

@ -1,28 +0,0 @@
void add()
{
int i,m=0;
char n;
char ch[2];
FILE *fp;
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
exit(1);
}
fseek(fp,0L,2);
printf("请输入单词: \n");
scanf("%s",inf[m].word);
printf("请输入释义:\n");
scanf("%s",inf[m].mean);
if(fwrite(&inf[m],LEN,1,fp)!=1)
{
printf("不能保存");
getchar();
}
else
{
printf("已保存\n");
m++;
}
fclose(fp);
}

@ -1,45 +0,0 @@
void enter()
{
int i,m=0;
char n;
char to[20],ch[2];
printf("请输入单词: ");
scanf("%s",to);
FILE *fp;
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
exit(1);
}
while(!feof(fp))
{
if(fread(&inf[m],LEN,1,fp)==1)
{
if(strcmp(to,inf[m].word)==0)
{
printf("释义: ");
printf("%s\n",inf[m].mean);
printf("是否继续?");
printf("按Y或y表示继续,按其它键返回\n");
scanf("%c",&n);
fclose(fp);
return;
}
}
m++;
}
printf("无此单词!\n");
printf("是否继续?");
printf("按Y或y表示继续,按其它键返回\n");
scanf("%c",&n);
fclose(fp);
return;
if(m==0)
printf("文件中无记录!\n");
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
return;
}
fclose(fp);
}
Loading…
Cancel
Save