| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 426 人关注过本帖
标题:请高手中的高手帮忙
只看楼主 加入收藏
百丈潭
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-7
收藏
 问题点数:0 回复次数:4 
请高手中的高手帮忙

大侠:谢谢你光顾我的程序,这程序已没错了,但是功能还是不能够完全显示出来,让小生见识下高手的利害
#include<conio.h>
#include<stdio.h>
#include<dos.h>
struct birth /*出生年月日结构定义*/
{
int year;
int month;
int day;
};
struct address
{
char address[60];
char mobile[13];
char family_tel[15];
char mail[25];
};
struct achieve
{
char degree[20];
char experience[1000];
};
struct worker
{
int number;
char name[20];
char sex;
char nation;
struct birth birth;
struct address address;
struct achieve achieve;
}workers[20];
FILE*fp;
int a;
void Data_load()
{
int b;
long c;
fp=fopen("worker.txt","r+t") ;
if(fp!=NULL)
{
for(a=1;a<20;a++)
{
if(fgetc(fp)==EOF)
return;
c=a-1;
fseek(fp,c*sizeof(struct worker),SEEK_SET);
fread(&workers[a],sizeof(struct worker),1,fp);
fclose(fp);
}
}
else
{
fp=fopen("worker.txt","w");
fclose(fp);
a=1;
}
}
void Data_Show(int b)
{
printf("\n\n\tNo:%3d\n",workers[b].number);
printf("\n\n\Name:%-20s\n\tsex:%c\n\tnation:%s\n",workers[b].name,workers[b].sex,workers[b].nation);
printf("\n\n\tBirthday(y/m/d):%4d%2d%2d",workers[b].birth.year,workers[b].birth.month,workers[b].birth.day);
printf("\n\n\tAddress:%-60s\n\tMobile:%13d\n\tFamily_tel:%15d\n\tmail:%-25s\n",workers[b].address.address,workers[b].address.mobile,workers[b].address.family_tel,workers[b].address.mail);
printf("\n\n\tDegree:%-20s\n\texperience:%-1000s\n",workers[b].achieve.degree,workers[b].achieve.experience);
getch();
}
void Data_Input(int b)
{
fflush(stdin);
workers[b].number=b;
printf("\n\n\tNo%d record",b);
printf("\n\n\tName");
scanf("%s",&workers[b].name);
getchar();
printf("\n\tnation:");
scanf("%s",&workers[b].nation);
getchar();
printf("\n\n\tsex(m/c):");
scanf("%c",&workers[b].sex);
getchar();
printf("\n\n\tbirthday:");
printf("\n\n\tyear:");
scanf("%c",&workers[b].birth.year);
printf("\n\n\tmonth:");
scanf("%d",&workers[b].birth.month);
printf("\n\n\tday:");
scanf("%d" ,&workers[b].birth.day);
printf("\n\n\t,address:");
scanf("%s",workers[b].address.address);
getchar();
printf("\n\n\tmobile:");
scanf("%c",&workers[b].address.mobile);
getchar();
printf("\n\n\tfamily_tel:");
scanf("%c",&workers[b].address.family_tel);
getchar();
printf("\n\n\tmail:");
scanf("%c", &workers[b].address.mail);
getchar();
printf("\n\n\tdegree:");
scanf("%s",&workers[b].achieve.degree);
getchar();
printf("\n\n\texperience:");
scanf("%s",&workers[b].achieve.experience);
}
void Data_Save()
{
int b;
fp=fopen("worker.txt","w");
for(b=1;b<=a;b++)
{
fwrite(&workers[b],sizeof(struct worker),1,fp);
}
fclose(fp);
}
main()
{
int b,c;
char ch,name[20];
char *search_name=name;
clrscr();
Data_load();
a--;
printf("\n\n\tFunction choose:");
printf("\n\t1.Read");
printf("\n\t2.Append");
printf("\n\t3.Delete");
printf("\n\t4.Search");
printf("\n\t5.Insert");
printf("\n\t6.Save and exit");
printf("\n\t7,Quit");
printf("\n\n");
printf("\t choice:");
scanf("%c",&ch);
switch(ch)
{
case '1':
b=1;
while(getch()!=0x1b&&b<=a) Data_Show(b++);
if(b>a)
printf("\n\tEnd of e_note\n");
break;
case '2':
while(getch()!=0x1b&&b<20)
{
a++;Data_Input(a);
}
if(a==20)
printf("\n\te_note is filled\n");
break;
case '3':
if(a<1)
{
printf("\n\tPlease Append record\n");
break;
}
printf("\n\t Dolete No:");
scanf("%d",&c);
for(b=c;b<a;b++)
{
strcpy(workers[b].name,workers[b+1].name);
strcpy(workers[b].sex,workers[b+1].sex);
strcpy(workers[b].nation,workers[b+1].nation);
strcpy(workers[b].birth.year,workers[b+1].birth.year);
strcpy(workers[b].birth.month,workers[b+1].birth.month);
strcpy(workers[b].birth.day,workers[b+1].birth.day);
strcpy(workers[b].address.address,workers[b+1].address.address);
strcpy(workers[b].address.mobile,workers[b+1].address.mobile);
strcpy(workers[b].address.family_tel,workers[b+1].address.family_tel);
strcpy(workers[b].address.mail,workers[b+1].address.mail);
strcpy(workers[b].achieve.degree[b+1],workers[b+1].achieve.degree);
strcpy(workers[b].achieve.experience,workers[b+1].achieve.experience);
}
a--;
break;
case'4':getchar();
printf("\n\t Please input name:");
gets(search_name);
for(b=0;b<=a;b++)
{
if(strcmp(search_name,workers[b].name)==0)
{
Data_Show(b);
break;
}
}
if(b>a)
{
printf("\n\t No such records");
}
break;
case '5':
printf("\n\tinsert No:");
scanf("%d",&c);
for(b=a+1;b>c;b--);
{
strcpy(workers[b].name,workers[b-1].name);
strcpy(workers[b].sex,workers[b-1].sex);
strcpy(workers[b].nation,workers[b-1].nation);
strcpy(workers[b].birth.year,workers[b-1].birth.year);
strcpy(workers[b].birth.month,workers[b-1].birth.month);
strcpy(workers[b].birth.day,workers[b-1].birth.day);
strcpy(workers[b].address.address,workers[b-1].address.address);
strcpy(workers[b].address.mobile,workers[b-1].address.mobile);
strcpy(workers[b].address.family_tel,workers[b-1].address.family_tel);
strcpy(workers[b].address.mail,workers[b-1].address.mail);
strcpy(workers[b].achieve.degree,workers[b-1].achieve.degree);
strcpy(workers[b].achieve.experience,workers[b-1].achieve.experience);
}
Data_Input(c);
a++;
Data_Save();
break;
case '6':
Data_Save();
exit(0);
break;
case '7':
printf("\n\t Do you want to save e_note:(y/n)");
ch=getch();
if(ch=='y')
{
Data_Save();
exit(0);
}
default: printf("please choose num 1-4\n");
}
}

2006-05-08 16:21
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
那么长的程序,你在任何一个论坛没有混个足够的人气是不会有人帮你看的..

淘宝杜琨
2006-05-08 16:22
lj_860603
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:714
专家分:0
注 册:2006-1-25
收藏
得分:0 
我想你应该把主要问题表达清楚.

我的原则很简单:不做不喜欢的事!
2006-05-08 16:42
wang12zx
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-5-4
收藏
得分:0 
你的程序是做什么的啊
2006-05-08 16:45
论坛
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1372
专家分:0
注 册:2006-3-27
收藏
得分:0 
楼主定义这么多结构

日出东方,唯我不败! 做任何东西都是耐得住寂寞,任何一个行业要有十年以上的积累才能成为专家
2006-05-08 16:46
快速回复:请高手中的高手帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013075 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved