c编写一个小型应用程序,实现从两个文件中提取信息,并生成一个新的文本文件

来源:百度知道 编辑:UC知道 时间:2024/06/20 09:16:23
要求:
编写一个小型应用程序,实现从两个文件中提取信息,并生成一个新的文本文件,生成的文件中包含:
学号,姓名,性别,语文成绩,数学成绩,英语成绩,总分
能根据命令行参数按学生的学号排序输出或按总分从高到低排序输出。

呵呵,满意的话要给我追加分哦!那两个例子都是我自己给你写的。
1.
#include"stdio.h"
#include"stdlib.h"
main()
{
FILE *fp;
char s[100];
if((fp=fopen("f:\\score.txt","a"))==NULL)
{
printf("Can't open destination file!\n");
exit(0);
}
printf("Please input your name:");
gets(s);
fprintf(fp,"Name:%s\t\tScore:%d\n",s,rand()%100);
fclose(fp);
printf("Your score is saved!\n");
}

2.
#include"stdio.h"
#define N 20
struct score
{
char s[20];
int a;
}d[N];
main()
{
FILE *fp;
int i,no=0;
if((fp=fopen("f:\\score.txt","r"))==NULL)
{
printf("Can't open destination file!\n");
exit(0);
}
for(i=0;i<N&&!feof(fp);i++)
{
fscanf(fp,"N