Before main(), then in main(), create the struct itself:
struct mystruct mine;
and now you have an array of twenty records. Pass mine around like any other array, to your other functions, and remember, at that point, mine is a pointer, not a full array (but you can modify it's members that way).
if(fread(&myArrayName[i++], sizeOfYourRecord, 1, FILE *pointer) < 2)
break; //fread returns the number of record members it stored)
ÝfreadÞ Reads data from a stream.
size_t fread(void *ptr, size_t size, size_t n, FILE *stream);
fread reads n items of data, each of length
size bytes, from the given input stream into a
block pointed to by ptr.
The total number of bytes read is (n x size).
On successful completion, fread returns the
number of items (not bytes) actually read.
It returns a short count (possibly 0) on
end-of-file or error.
fread is available on all UNIX systems and is
defined in ANSI C.
fopen fwrite printf read
char msg = "this is a test";
if ((stream = fopen("DUMMY.FIL", "w+"))
fprintf(stderr, "Cannot open output file.\n");
/* write some data to the file */
fwrite(msg, strlen(msg)+1, 1, stream);
/* seek to the beginning of the file */
fseek(stream, SEEK_SET, 0);
/* read the data and display it */
fread(buf, strlen(msg)+1, 1, stream);