1. 程式人生 > >C/C++.全檔名全路徑名分割拆分分解

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、