用_makepath和_splitpath构造路径&分解路径

#include <iostream>
#include <cstdlib>

using namespace std;


const int MAX_PATH_ = 256;
const int MAX_DRIVE = 16;
const int MAX_DIR = 128;
const int MAX_FILE_NAME = 128;
const int MAX_EXT = 32;

char szPath[MAX_PATH_];
char szDrive[MAX_DRIVE];
char szDIR[MAX_DIR];
char szFName[MAX_FILE_NAME];
char szExt[MAX_EXT];

void Split(const char* szFileName)
{
    if (szFileName == NULL)
        return;
    _splitpath(szFileName, szDrive, szDIR, szFName, szExt);
}

int main()
{
    _makepath(szPath, "c", "//sample//myprogarm//","makepath", "txt" );
    Split(szPath);
    cout<<szPath<<endl;
    cout<<szDrive<<endl;
    cout<<szDIR<<endl;
    cout<<szFName<<endl;
    cout<<szExt<<endl;
}

你可能感兴趣的:(c,File,ext,null,Path,include)