I've recently noticed that if I use the tellg() function then it doesn't return the ammount of binary numbers in a file but the ammount of characters plus the '\r' signs.
This happens no matter if I use ios::binary as flag or not.
The problem is that if you then use read and put how long the file was into the second argument it doesn't add those '\r' by itself and still it demands them. All this put together means that you can't use this method unless it's a one line file.
Code:int main () { char * buffer; long size; ifstream file (filename, ios::in|ios::binary|ios::ate); size = file.tellg(); file.seekg (0, ios::beg); buffer = new char [size]; file.read (buffer, size); file.close(); cout << "the complete file is in a buffer"; delete[] buffer; return 0; }



LinkBack URL
About LinkBacks



