+ 1

C ćŸȘćșæȘ”

#include <stdio.h> #include <stdlib.h> struct Student { char name[7]; char tel[11]; int score1; int score2; }; int main() { FILE *file; Student *data = NULL; file = fopen("C:\\Users\\yan\\Desktop\\student.txt", "r"); if (!file) return 0; char name, tel; int score1, score2, count = 0; while (!feof(file)) { fscanf(file, "%s %s %d %d", &name, &tel, &score1, &score2); count++; } fclose(file); data = new Student[count]; file = fopen("C:\\Users\\yan\\Desktop\\student.txt", "r"); for (int i = 0; i < count; i++) { fscanf(file, "%s %s %d %d", data[i].name, data[i].tel, &(data[i].score1), &(data[i].score2)); } fclose(file); for (int i = 0; i < count; i++) { printf("%s %s %d %d\n", data[i].name, data[i].tel, data[i].score1, data[i].score2); } system("pause"); return 0; } ćŻä»„èŒžć‡șèł‡æ–™äœ†ïŒŒćŸ·èĄŒç”æŸæœƒè·‘ć‡ș錯èȘ€đŸ˜­

7th Jun 2019, 3:23 AM
yan yu
yan yu - avatar
1 Answer
0
Please tell it in the english... I may help you..
8th Jun 2019, 1:01 PM
Shakti Vishwakarma
Shakti Vishwakarma - avatar