/** * Reading an array of pointers to structures * This program MUST be aligned with the writer * @author gtowell * Created: April 2021 * **/ #include #include typedef struct { int aa; double bb; } aabb; int main(int argc, char const *argv[]) { aabb **arr; FILE *fp = fopen("astrfp", "r"); int d; fread(&d, sizeof(int), 1, fp); arr = malloc(d * sizeof(aabb *)); for (int i = 0; i < d; i++) { arr[i] = malloc(1 * sizeof(aabb)); fread(arr[i], sizeof(aabb), 1, fp); } fclose(fp); for (int i = 0; i < d; i++) printf("%d %f\n", arr[i]->aa, arr[i]->bb); return 0; }