Hello!
I'm trying to get the contents of a binary file into a char array, my read function is in main.cpp, in the header file is referenced as char fileio(char * bufferZ) , and is called in another .cpp file.
The problem is , the code in the function cant get the length of files that are larger than about 10 KB.The length gets to 0.
The read file function is:
char fileio(char * bufferZ){
// get file size method 1
long begin,end;
ifstream myfile ("1.im");
begin = myfile.tellg();
myfile.seekg (0, ios::end);
end = myfile.tellg();
myfile.close();
ifstream is;
int length;
is.open ("1.im", ios::binary );
// get file size method 2
is.seekg (0, ios::end);
length = is.tellg();
is.seekg (0, ios::beg);
//is.read (bufferZ,length);
is.read (bufferZ, (end-begin) );
is.close();
}
I'm using this in a winapi program.