When you want to read strings, you should use >> operator, std::getline or a similar function. fstream::read is designed for binary files. It does not append a null char in the end to make a cstring.
If you, for some reason, wish to use fstream::read, you can append 0 manually: buffer[length-1] = 0;