Original Post
I'm trying to write a simple function that loads an uncompressed 24 bit bitmap from a file. I have the BMPFILEHEADER and BMPINOFHEADER structures all set up, but my question is how do I use ifstream exactly to pull this information out of the file and into my structure?
for instance...
void loadBMP(const char * filename)
{
struct BMPFILEHEADER fileHeader;
std::ifstream fin(filename);
if(!fin)
return;
// let's say i want to load the first field of the
// BMPFILEHEADER structure.
// bfType is an unsigned short
fin >> fileHeader.bfType;
// etc. etc. I would load all the rest of the fields
}
Is this how ifstream is used? I've searched the net for tutorials on file streams but every tutorial i've seen only loads character strings from files, never ints or floats or anything like that.
[edited by - Malone1234 on July 17, 2003 2:06:14 AM]