Answers for "c++ file name without extension"

C++
0

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;
}
Posted by: Guest on July-16-2021

Code answers related to "c++ file name without extension"

Browse Popular Code Answers by Language