I'm trying to read a text fiel under Windows:
Expand|Select|Wrap|Line Numbers
- long size;
- ifstream file (name, ios::ate); //open and goes at the end
- size = file.tellg(); //it takes 181
- _buffer = new char [size];
- file.seekg (0, ios::beg);
- file.read (_buffer, size);
- size = file.gcount(); //it takes 168
- // _buffer[size] = '\0';
My problem is start when I did "cout << _buffer;" and I saw at its end there were some strange characters that weren't in the file; so I thought that they were the dirty memory....
Then, how do I have to proceed, please? Do I have to set '\0'? But wich position at? Do I have to call memset() to clear to memory?
Some hints, please....