Maxbad`Blog

API:路径分割 _splitpath_s()

2020-11-26 · 1 min read
#include <iostream>  
#include <cstdlib>  
using namespace std;  
  
int main()  
{  
    char *path="c:\\111\\222\\xxxx.mp3";  
    char drive[5];  
    char dir[100];  
    char filename[100];  
    char fileext[10];  
    _splitpath(path,drive,dir,filename,fileext);  
    cout<<"filepath: "<<path<<endl  
        <<"drive: "<<drive<<endl            // c:
        <<"dir: "<<dir<<endl                    // \111\222\
        <<"filename: "<<filename<<endl      // xxx
        <<"fileext: "<<fileext<<endl;       // .mp3
    system("pause");  
    return 0;  
}