reading a file into a block
Hello,
I've done this:
Code:
long size;
ifstream file (name, ios::ate); //open and go at the end
size = file.tellg();
char* _buffer = new char [size];
//memset( _buffer, 0, size ); //without this strange there are characters
file.seekg (0, ios::beg);
file.read (_buffer, size);
cout << _buffer << endl;
file.close;
delete[] _buffer;
Problem is when I print it: some strange chars (that there aren't in the file) occurs at the end of the _buffer; Why? How can I avoid this? What wrong?