Well there's not a lot to go on.
Here's an example of how to declare arrays, structs, and read/write them to files in binary mode.
Code:
#include <stdio.h>
#define LEN 5
struct foo {
int a;
};
int main( ) {
struct foo array[LEN];
// fill it
for ( int i = 0 ; i < LEN ; i++ ) {
array[i].a = i;
}
// write it
FILE *fp = fopen("testfile1.bin","wb");
for ( int i = 0 ; i < LEN ; i++ ) {
fwrite(&array[i].a,sizeof(array[i].a),1,fp);
}
// Same again, but write a whole struct instance at once
fp = fopen("testfile2.bin","wb");
for ( int i = 0 ; i < LEN ; i++ ) {
fwrite(&array[i],sizeof(array[i]),1,fp);
}
fclose(fp);
struct foo input[LEN];
// read it
fp = fopen("testfile2.bin","rb");
for ( int i = 0 ; i < LEN ; i++ ) {
fread(&input[i],sizeof(input[i]),1,fp);
}
fclose(fp);
// print it
for ( int i = 0 ; i < LEN ; i++ ) {
printf("Value at index %d is %d\n", i, input[i].a);
}
return 0;
}
Results
Code:
$ gcc main.c
$ ./a.out
Value at index 0 is 0
Value at index 1 is 1
Value at index 2 is 2
Value at index 3 is 3
Value at index 4 is 4
$ hd testfile1.bin
00000000 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 |................|
00000010 04 00 00 00 |....|
00000014
$ hd testfile2.bin
00000000 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 |................|
00000010 04 00 00 00 |....|
00000014