A表:sno sname 001 a 002 b 003 c B表; score 90 98 98 请问如何将B表的成绩直接加到A表上面

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 07:50:28
A表:sno sname 001 a 002 b 003 c B表; score 90 98 98 请问如何将B表的成绩直接加到A表上面

A表:sno sname 001 a 002 b 003 c B表; score 90 98 98 请问如何将B表的成绩直接加到A表上面
A表:sno sname 001 a 002 b 003 c B表; score 90 98 98 请问如何将B表的成绩直接加到A表上面

A表:sno sname 001 a 002 b 003 c B表; score 90 98 98 请问如何将B表的成绩直接加到A表上面
楼主参考下这个程序,里面有合并两个文件的
#include
#define SIZE 1024
char buffer[SIZE];
FILE *fp1,*fp2;
double sizef,ev_sizef;
void menu123();
void divide123();
void unite123();
void unitefile123();
main()
{
menu123();
}
void menu123() /*主界面的选择菜单*/
{
int n;
/* clrscr();/*清除整个当前字符窗口,并且把光标定位于左上角(1,1)处*/
do
{
printf("\nplease choose you needful file:1.divide file 2.unite file 3.exit :");
scanf("%d",&n);
if(n==1)
divide123();
else
if(n==2)
unite123();
else
if(n==3)
exit(0);
}while(n3);
}
void unite123() /*合并文件*/
{
int n;
char name[25],c;
lp:
lp1:
printf("\nplease input unite file's postion:");
scanf("%s",name);
if((fp1=fopen(name,"wb"))==NULL)
{
printf("\nthe postion is error,whether or not repeate input(Y/N):");
getchar();
c=getchar();
if(c=='Y'||c=='y')
goto lp1;
else
menu123();
}
unitefile123();
printf("\nunitefile successful,whether or not continue to unite the other files(Y/N):");
getchar();
c=getchar();
if(c=='Y'||c=='y')
goto lp;
else
menu123();
}
void unitefile123() /*合并文件*/
{
int i=1;
char name[25],c;
do
{
lp1:
printf("\nplease input you want to uniting %d new file's postion:",i++);
scanf("%s",name);
if((fp2=fopen(name,"rb+"))==NULL)
{
printf("\nyou input the file postion is error,whether or not input the new name(Y/N):");
if(getchar()=='Y'||getchar()=='y')
goto lp1;
else
menu123();
}
while(fread(buffer,1,1,fp2))
fwrite(buffer,1,1,fp1);
fclose(fp2);
printf("\nwhether or not continue to unite(Y/press any key):");
getchar();
c=getchar();
}while(c=='y'||c=='Y');
fclose(fp1);
}
void divide123() /*分割文件*/
{
int n;
char name[25],c;
lp:
lp1:
printf("\nplease input divide file's postion:");
scanf("%s",name);
if((fp2=fopen(name,"rb"))==NULL)
{
printf("\nthe postion is error,whether or not repeate input(Y/N):");
getchar();
c=getchar();
if(c=='Y'||c=='y')
goto lp1;
else
menu123();
}
printf("\nhow many do you want to divide the file:");
lp2:
scanf("%d",&n);
if(n