#include <stdlib.h>
#include <stdio.h>
#define _MAX_PATH 260//max length of full pathname
#define _MAX_DRIVE 3 //max length of drive component
#define _MAX_DIR 256 //max length of path component
#define _MAX_FNAME 256 //max length of file name component
#define _MAX_EXT 256 //max length of extension component
void main(){
char full_path[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_makepath(full_path,"c","\\sample\\file\\","makepath","c");
printf("_Full_path created with _makepath:%s\n\n",full_path);
_splitpath(full_path,drive,dir,fname,ext);
printf("Path extracted with _splitpath:\n");
printf(" _Drive: %s\n",drive);
printf(" _Dir: %s\n",dir);
printf("_Filename: %s\n",fname);
printf(" _Ext: %s\n",ext);
//output
_FullPath created with _makepath: c:\sample\file\makepath.c
Path extracted with _splitpath;
_Drive: c;
_Dir: \sample\file\
_Filename: makepath
_Ext: .c
}
string filePath = "E:\\file\\main.cpp";
string extendName;
int iBeginIndex = filePath.find_last_of(".")+1;
int iEndIndex = filePath.length();
extendName = filePath.substr(iBeginIndex,iEndIndex-iBeginIndex);
transform(extendName.begin(),extendName.end(),extendName.begin(),tolower);
cout<<extendName<<endl;
#include <stdio.h>
#define _MAX_PATH 260//max length of full pathname
#define _MAX_DRIVE 3 //max length of drive component
#define _MAX_DIR 256 //max length of path component
#define _MAX_FNAME 256 //max length of file name component
#define _MAX_EXT 256 //max length of extension component
void main(){
char full_path[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_makepath(full_path,"c","\\sample\\file\\","makepath","c");
printf("_Full_path created with _makepath:%s\n\n",full_path);
_splitpath(full_path,drive,dir,fname,ext);
printf("Path extracted with _splitpath:\n");
printf(" _Drive: %s\n",drive);
printf(" _Dir: %s\n",dir);
printf("_Filename: %s\n",fname);
printf(" _Ext: %s\n",ext);
//output
_FullPath created with _makepath: c:\sample\file\makepath.c
Path extracted with _splitpath;
_Drive: c;
_Dir: \sample\file\
_Filename: makepath
_Ext: .c
}
string filePath = "E:\\file\\main.cpp";
string extendName;
int iBeginIndex = filePath.find_last_of(".")+1;
int iEndIndex = filePath.length();
extendName = filePath.substr(iBeginIndex,iEndIndex-iBeginIndex);
transform(extendName.begin(),extendName.end(),extendName.begin(),tolower);
cout<<extendName<<endl;