- 18
- 0
- 约7.95千字
- 约 18页
- 2019-03-10 发布于安徽
- 举报
.
...
#include stdio.h
#include stdlib.h
#include conio.h
#include string.h
void menu();//功能选择
void lkp();//查看信息
void chng();//修改信息
void dlt();//删除信息
void add();//添加信息
void read();//读取文件
void write();//写入文件
void count();//统计信息
struct dvc
{
char dno[20],dname[20],downer[20],ddpartment[20],damount[20],dtime[20],dprice[20];
int dlt;
} d[200];
int tot,sum;
int main()
{
system(color fc);
system(mode con cols=146 lines=40);
puts( ************************);
puts( *欢迎使用设备管理系统!*);
puts( ************************);
read();//将保存至外存中的文件读进内存
menu(); //用户功能选择
write(); //将内存里的所有信息覆写回外存文件中
system(cls);
puts(感谢您的使用);
return 0;
}
void read()
{
tot=0;
FILE *fp=fopen(D:\\inf.txt,r);
if(fp==NULL)
{
fp=fopen(D:\\inf.txt,w);
fclose(fp);
}
while (fscanf(fp, %s %s %s %s %s %s %s,d[tot].dno,d[tot].dname,d[tot].downer,d[tot].ddpartment,d[tot].damount,d[tot].dtime,d[tot].dprice)!=EOF)
{
d[tot++].dlt=0;
}
fclose(fp);
}
void write()
{
int i;
FILE *fp=fopen(D:\\inf.txt,w);
for (i=0;itot;i++)
if (!d[i].dlt)
fprintf(fp,%s %s %s %s %s %s %s\n,d[i].dno,d[i].dname,d[i].downer,d[i].ddpartment,d[i].damount,d[i].dtime,d[i].dprice);
fclose(fp);
}
void menu()
{
char a;
while (1)
{
puts(★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★请选择需要的功能:★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★);
puts( 1.查看所有设备信息\n 2.修改设备信息\n 3.删除设备信息\n 4.增加设备信息\n 5.统计设备信息\n 0.退出系统);
a=getch();
switch (a)
{
case 0:return;
case 1:{
lkp();
break;
}
case
原创力文档

文档评论(0)