C/C++.全文件名全路径名分割拆分分解

1、_splitpath

  ZC:windows api的话 可以使用 PathFindFileNameA、PathFindExtensionA、PathFileExistsA等一系列函数

2、测试代码(_splitpath)(vs2008 Win32)

  2.1、

#include <direct.h> //_mkdir函数的头文件
#include <io.h>     //_access函数的头文件

#include <stdio.h>
#include <windows.h>
    char* pc = "D:\\G_DR_2018\\_G2SVG_Console_VS08\\LOG\\zz.txt";
    //char fullPath[MAX_PATH];
    char drive[_MAX_DRIVE] = {0};
    char dir[_MAX_DIR] = {0};
    char fname[_MAX_FNAME] = {0};
    char ext[_MAX_EXT] = {0};
    _splitpath( pc, drive, dir, fname, ext );
    printf("drive: %s\n", drive);
    printf("dir: %s\n", dir);
    printf("fname: %s\n", fname);
    printf("ext: %s\n", ext);

    

  2.2、

    char* pc = "D:\\G_DR_2018\\_G2SVG_Console_VS08\\LOG\\";
    ... ...

    

  2.3、这里 需要注意一下下面的现象

    char* pc = "D:\\G_DR_2018\\_G2SVG_Console_VS08\\LOG";
    ... ...

    

3、

4、

5、

猜你喜欢

转载自www.cnblogs.com/cppskill/p/9889377.html
今日推荐