I have a class:
class ByteBuffer
{
//other methods that work on the Buffer
private:
std::vector<char> Buffer;
};
also
class File
{
FILEHEADER Header;
ByteBuffer Data;
};
The Data is a vector as you can see that is filled with data that was loaded from a different file. Header is valid also, and contains nothing but the type of file. Now I'm trying to writ this to a file like this:
//File ImageFile; defined and intialized elesewhere
ofstream OutFile(filename.c_str(), ios::binary);
OutFile.write((char*)&ImageFile, ImageFile.GetSize());
OutFile.close();
I get an access violation when I run the app. I debugged and I know that the ImageFile is getting initialized properly and the Header as well as the Data are all correct. Also the Data contains another file (bitmap) that I read in earlier, so the Data has to be valid. I also tried different sizes for write() it writes just fine up to about 15kb then somewhere at 19kb it gives me the error. Can someone please tell me what it's trying to read and how I figure out what the problem is? Thanks.