currently I only know something like:

fstream fstream_Object.open(/*opening info here*/);

and looping

"fstream_Object<<Atomic_type_to_file;" or "fstream_Object>>Atomic_type_from_file;"

to get information saved to and from a file. I'm trying to learn how to use binary input and output. I looked up .bmp specifications and learned that binary files need to have a "fileheader" a "infoHeader"and a "data block" that all work together somehow.

So the question is how dose puting the three together work?
Is the file header similar to creating a "struct" and then the info header tells you where in the data block to fill each saved struct and how many?

A simpler example than a .bmp file might be something like:

struct Elements
{
unsigned int number;
unsigned int weight;
};
Elements element[118];

and place this into a file with it's own header and such.