I stopped coding for about a year and a half ago. So I'm trying to find things to brush up on. At the moment it's file i/o.
I'm not exactly sure what is wrong with my code, but when I go to check what I loaded into memory by outputting it to the consol, I am getting weird numbers.
The only value that seems to come out true is the first one which is always going to be "19778"Code:#include <fstream> using namespace std; class BitmapPic { private: //bitmap fileheader(info about file) typedef struct Bitmap_FileHeader { unsigned short bfType;//WORD unsigned long bfSize;//DWORD unsigned short bfReserved1; unsigned short bfReserved2; unsigned long bfOffBits; };//total:14 bytes //bitmap infoheader:(info on contents of file) typedef struct Bitmap_InfoHeader { unsigned long biSize;//DWORD unsigned long biWidth; unsigned long biHeigth; unsigned short biPlanes;//WORD unsigned short biBitCount; unsigned long biCompression; unsigned long biSizeImage; unsigned long biXPelsPerMeter; unsigned long biYPelsPerMeter; unsigned long biClrUsed; unsigned long biClrImportant; };//total: 40 bytes //structure for containing pixel values. typedef struct RGBQuad { unsigned char rgbBlue; unsigned char rgbGreen; unsigned char rgbRed; unsigned char rgbReserved; }; public: Bitmap_FileHeader bmfh; Bitmap_InfoHeader bmih; RGBQuad aColors[]; void LBmp(char file[]); }; void BitmapPic::LBmp(char file[]) { ifstream infile(file,ios::binary|ios::in); infile.read(reinterpret_cast<char*>(&bmfh),sizeof(Bitmap_FileHeader)); infile.read(reinterpret_cast<char*>(&bmih),sizeof(Bitmap_InfoHeader)); }
bfSize comes out as 0
biWidth comes out as 18808832
biHeigth comes out as 65536 (2^16)