请问这个用C语言怎么编?【追加悬赏】

来源:百度知道 编辑:UC知道 时间:2024/06/05 14:13:30
题目是这样的:输入M个学生的信息,输出到文件stu.txt,然后从这个文件中读取信息排序后输出到stu1.txt。

PS:特别是怎么从文件中读取数据然后输出到文件stu1里面,其他的可以用省略号代替,谢谢啦!!
书我看过了,但是很奇怪输出的都是地址,但是单独用那个命令的话就不会出现这种情况。
我本来想把程序发上来的,百度说内容太长,不让发。

不知道记录有多少条?
不知道你想按照什么排序?
信息有何特征

百度不让发
就发到我的邮箱里(连同数据)
wxw12345@qq.com

#include <stdio.h>
#include <stdlib.h>
#define M 2
#define LEN 25

struct student{ //创建结构体数组
int no;
char name[LEN+1];
int age;
char sex[LEN];
}stu[M];

void sort(struct student stu1[]);

void main()
{
struct student stu1[M];
FILE *fp2;
int i;
FILE *fp1;
if((fp1=fopen("stu.txt","w"))==NULL)
printf("stu.txt can not open.");
if((fp2=fopen("stu1.txt","w"))==NULL)
printf("Can not open stu1.");
for(i=0;i<M;i++)
{
printf("Enter the information of student(number,name,age,sex(f/m)) %d:",i+1);
scanf("%d%s%d%s",&stu1[i].no,&stu1[i].name,&stu1[i].age,&stu1[i].