I convert this code in python to c++:
content = file(filename, "rb").read()
this is the code in c++:
ifstream file;
file.open(filename, fstream::binary);
file.seekg (0, ios::end);
long fileLength = file.tellg();
file.seekg(0, ios_base::beg);
char *content = new char[fileLength];
file.read(content, fileLength);
when I run the python code I get a long string in the content (500 characters~) while the c++ code return only 4 characters.
any suggestion?
thanks
The simplest way to read an entire file is: