Here's my function for getting the length of a file, in characters:unsigned int GetFileLength(std::string FileName){std::ifstream InFile(FileName.c_str());unsigned int FileLength = 0;while (InFile.get() != EOF) FileLength++; InFile.close();return FileLength;}How can this be improved?
Getting the length of a file in characters
c++;file
Just seek to the end of the file and grab the value:ifstream is;is.open (FileName.c_str(), ios::binary );is.seekg (0, ios::end);length = is.tellg();