fread() a struct in c
问题 For my assignment, I'm required to use fread/fwrite. I wrote #include <stdio.h> #include <string.h> struct rec{ int account; char name[100]; double balance; }; int main() { struct rec rec1; int c; FILE *fptr; fptr = fopen("clients.txt", "r"); if (fptr == NULL) printf("File could not be opened, exiting program.\n"); else { printf("%-10s%-13s%s\n", "Account", "Name", "Balance"); while (!feof(fptr)) { //fscanf(fptr, "%d%s%lf", &rec.account, rec.name, &rec.balance); fread(&rec1, sizeof(rec1),1,