/** * Writing an array of pointers to structures using fwrite. * THIS PROGRAM IS WRONG * @author gtowell * Created: April 2021 * **/ #include #include #include #define SIZ 100 typedef struct { int aa; double bb; } aabb; int main(int argc, char const *argv[]) { aabb* arr[SIZ]; for (int i = 0; i < SIZ; i++) { arr[i] = malloc(1 * sizeof(aabb)); arr[i]->aa = i; arr[i]->bb = sqrt(i); } FILE *fp = fopen("astrfp", "w"); fwrite(arr, sizeof(aabb), SIZ, fp); // problem here fclose(fp); return 0; }