/** * Reading an aray of structures * This you must know the number of structures to read * and the exact definition of the structure * As it stand in this file, this program will fail * because the structure definition here is NOT identical * to the structure defintion in rstr.c * * @author gtowell * Created: April 2021 * **/ #include #define SIZ 100 typedef struct { double bb; int aa; } aabb; int main(int argc, char const *argv[]) { aabb arr[SIZ]; FILE *fp = fopen("astr", "r"); fread(arr, sizeof(aabb), SIZ, fp); fclose(fp); for (int i = 0; i < SIZ; i++) printf("%d %f\n", arr[i].aa, arr[i].bb); return 0; }