Writing large values to a file

Ok folks, my brain must be completely asleep today because this one is stumping me big-time...
I have a function that writes out 83 bytes of information for my game. All of the data, except for six fields, are unsigned char's (simple flags and options, a couple of coordinates that are always 0-255, etc). I have a buffer defined as...
unsigned char* outBuffer = (unsigned char*)malloc(83);
...that I put all the data into, then write it out. It works perfectly well for just about all of the data I'm working with, no problem.
However, the six fields I alluded to are DWORD variables, so of course that's the equivalent of 4 unsigned char's.
Here's my question... how do I write them out to my file (really, how do I insert them into my buffer) without losing precision? The code I'm using for the other fields is basically:
int indexer = 0;
*(outBuffer + indexer++) = (unsigned char)volumeLevel;
*(outBuffer + indexer++) = (unsigned char)currentGameLevel;
// ... and so on...
...for the most part the casts aren't necassery, but since some of the variables are actualy ints (that are always in the range of an unsigned char anyway), I do it all the time just to be safe. I of course can't just casts a DWORD to an unsigned char because I'd lose information.
So, I guess another way of asking this is how can I break a DWORD into the four bytes that make it up, write them out, and then re-constitute the four bytes into a DWORD when I read the file back in?
TIA!
I have a function that writes out 83 bytes of information for my game. All of the data, except for six fields, are unsigned char's (simple flags and options, a couple of coordinates that are always 0-255, etc). I have a buffer defined as...
unsigned char* outBuffer = (unsigned char*)malloc(83);
...that I put all the data into, then write it out. It works perfectly well for just about all of the data I'm working with, no problem.
However, the six fields I alluded to are DWORD variables, so of course that's the equivalent of 4 unsigned char's.
Here's my question... how do I write them out to my file (really, how do I insert them into my buffer) without losing precision? The code I'm using for the other fields is basically:
int indexer = 0;
*(outBuffer + indexer++) = (unsigned char)volumeLevel;
*(outBuffer + indexer++) = (unsigned char)currentGameLevel;
// ... and so on...
...for the most part the casts aren't necassery, but since some of the variables are actualy ints (that are always in the range of an unsigned char anyway), I do it all the time just to be safe. I of course can't just casts a DWORD to an unsigned char because I'd lose information.
So, I guess another way of asking this is how can I break a DWORD into the four bytes that make it up, write them out, and then re-constitute the four bytes into a DWORD when I read the file back in?
TIA!