If you haven't already, grab a .BMP format reference
from Wotsit - the (Windows) BMP header is a bit more than resolution

For the sake of not going insane, define the header as a C struct - or if you feel like going all-in, a C++ class. You should end up with either a struct and a write_to_file() function that takes a file and a header struct as arguments, or a C++ class with a write_to_file member function (we'll save proper C++ iostreams to quite a bit later

).
Now, for file I/O, you have a lot of options. You can go for low-level file routines, C-style FILE* streams, or C++ iostreams. Low-level and FILE* are pretty much the same: they let you write out X bytes at a time. C++ iostreams are focused with writing "objects" - but you can also use them to write out bytes.
Writing out the header - the safe and portable way is to write out each member of the header structure one by one (basically making sure you're only ever writing C primitive types). This works, but can be pretty slow for large structures - we're talking huge then, though. You'd probably be tempted to simply write out the header in one go, but this won't work because of the memory padding the compiler does for speed. You can tell it to not do this packing, but that is unportable - beware if you ever plan on supporting "queer" platforms. When dealing with binary file formats, you'll want to define types (or find a stdint.h, if it doesn't come with your compiler (*cough* Visual C++ *cough*)) that have the correct bitsize.
So... which file I/O routines do you currently use, and how have you defined the header?
