#include <stdio.h>
#define N 2
int main()
{
int i;
FILE *fp;
FILE *fpp;
struct stu
{
char name[10];
int number;
int score;
}stud[N];
fp = fopen("stu.txt", "w");
for(i = 0; i < N; i++)
{
printf("input imformation:\n");
printf("name:");
scanf("%s", &stud[i].name);
printf("number:");
scanf("%d", &stud[i].number);
printf("score:");
scanf("%d", &stud[i].score);
fprintf(fp, "%s, %d, %d\n", stud[i].name, stud[i].number, stud[i].score);
}
fclose(fp);
fpp = fopen("stu.txt", "r");
for(i = 0; i < N; i++)
{
if(stud[i].score > 550.0)
printf("%sNO:%d is excellent student\n", stud[i].name, stud[i].number);
}
fclose(fpp);
getch();
return 0;
}
你慢慢研究吧!
#define N 2
int main()
{
int i;
FILE *fp;
FILE *fpp;
struct stu
{
char name[10];
int number;
int score;
}stud[N];
fp = fopen("stu.txt", "w");
for(i = 0; i < N; i++)
{
printf("input imformation:\n");
printf("name:");
scanf("%s", &stud[i].name);
printf("number:");
scanf("%d", &stud[i].number);
printf("score:");
scanf("%d", &stud[i].score);
fprintf(fp, "%s, %d, %d\n", stud[i].name, stud[i].number, stud[i].score);
}
fclose(fp);
fpp = fopen("stu.txt", "r");
for(i = 0; i < N; i++)
{
if(stud[i].score > 550.0)
printf("%sNO:%d is excellent student\n", stud[i].name, stud[i].number);
}
fclose(fpp);
getch();
return 0;
}
你慢慢研究吧!
仰望星空...........不忘初心!