c 2b 2b file name without extension

Solutions on MaxInterview for c 2b 2b file name without extension by the best coders in the world

showing results for - "c 2b 2b file name without extension"
Mya
26 Nov 2016
1// The GetFilenameExcludingExtension function does the trick. Just make sure it is defined below the GetFileExtension function
2
3#include <iostream>
4using namespace std;
5
6string GetFileExtension(string Filename)
7{
8   size_t LastDot = Filename.find_last_of(".");
9
10   if (LastDot == string::npos)
11   {
12      return ""; // No extension in Filename string
13   }
14
15   return Filename.substr(LastDot);
16}
17
18string GetFilenameExcludingExtension(string Filename)
19{
20   string Extension = GetFileExtension(Filename);
21   string NameExclExt = Filename.substr(0,Filename.length() - Extension.length());
22
23   return NameExclExt;
24}
25