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、

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM