You don't need a struct.
Your problem is that all you're writing to the file is the two pointers in the struct, and no actual data at all. The values of the pointers are useless when read back in.
Here's an example of reading and writing an integer array to a binary file.
Code:
/* binwrite.c */
#include <stdio.h>
#include <stdlib.h>
void die(const char *msg) {
perror(msg);
exit(1);
}
int main(void) {
int a[] = {1, 2, 3, 4, 5};
size_t i;
FILE *fp;
fp = fopen("data.bin", "wb");
if (!fp) die("Can't open data.bin for writing");
for (i = 0; i < sizeof a/sizeof*a; i++)
fwrite(&a[i], sizeof*a, 1, fp);
fclose(fp);
return 0;
}
Code:
/* binread.c */
#include <stdio.h>
#include <stdlib.h>
void die(const char *msg) {
perror(msg);
exit(1);
}
int main(void) {
int a[5];
size_t i, n = 0;
FILE *fp;
fp = fopen("data.bin", "rb");
if (!fp) die("Can't open data.bin for reading");
while (fread(&a[n], sizeof*a, 1, fp) == 1)
n++;
fclose(fp);
for (i = 0; i < n; i++)
printf("%d\n", a[i]);
return 0;
}