c++ file name without extension
// The GetFilenameExcludingExtension function does the trick. Just make sure it is defined below the GetFileExtension function
#include <iostream>
using namespace std;
string GetFileExtension(string Filename)
{
size_t LastDot = Filename.find_last_of(".");
if (LastDot == string::npos)
{
return ""; // No extension in Filename string
}
return Filename.substr(LastDot);
}
string GetFilenameExcludingExtension(string Filename)
{
string Extension = GetFileExtension(Filename);
string NameExclExt = Filename.substr(0,Filename.length() - Extension.length());
return NameExclExt;
}