Original Post
I've often done my input this way for binary files and it always worked perfectly but it creates garbage at the end of the string when using plain text :
I thought it might be that somehow there was no null character to terminate the string but that's not it either.
-Puzzled
[edited by - Dark Rain on February 21, 2003 1:05:00 AM]
std::ifstream inputFile( nomFichier.c_str(), std::ios::in );
if ( inputFile.fail())
{
//Code that error log obj someday
return "";
}
inputFile.seekg( 0, std::ios::end );
long fileSize = inputFile.tellg();
inputFile.seekg( 0, std::ios::beg );
char *pBuffer = new char[fileSize];
inputFile.read( pBuffer, fileSize );
inputFile.close();
std::string Content = pBuffer;
delete[] pBuffer;
return Content;