Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::string code snippet to r emove a filename's extension.
* View the code of 'RemoveEntension' in plain text
#include <string>
#include <cassert>
//From http://www.richelbilderbeek.nl/CppRemoveExtension.htm
const std::string RemoveExtension(const std::string& filename)
{
const int dot_index = filename.rfind(".",filename.size());
assert(dot_index != -1 && "No dot found in filename");
return filename.substr(0,dot_index);
}
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.