c 路径

拆分路径_splitpath_s(安全)对应宽字符 _wsplitpath_s
errno_t _splitpath_s( char const* _FullPath, // 拆分的路径
char* _Drive, //盘符
size_t _DriveCount,
char* _Dir, //路径
size_t _DirCount,
char* _Filename, //文件名
size_t _FilenameCount,
char* _Ext, //扩展名
size_t _ExtCount
);

char Fullpath[_MAX_PATH] = { 0 };
     strcpy(Fullpath, "G:\\c\\hello\\hello.txt");
     char Dir[_MAX_DIR] = { 0 };
     char Drive[_MAX_DRIVE] = { 0 };
     char Filename[_MAX_FNAME] = { 0 };
     char Extension[_MAX_EXT] = { 0 };
     errno_t err= _splitpath_s(Fullpath,Drive, _MAX_DRIVE,Dir,_MAX_DIR, Filename, _MAX_FNAME, Extension, _MAX_EXT);
     if (err==0)
     {
         printf("Success \n");
     }

组合路径_makepath_s 对应宽字符_wmakepath_s

errno_t _makepath_s( char* _Buffer, size_t _BufferCount, char const* _Drive, char const* _Dir, char const* _Filename, char const* _Ext);

char path[_MAX_PATH] = { 0 };
    errno_t errmsg=_makepath_s(path, _MAX_PATH, "g", "\\c\\path\\text", "hello", "txt");
    if (errmsg!= 0)
    {
        printf("Error \n");

    }

将当前的相对路径转化为绝对路径
char* _fullpath(
char* _Buffer,
char const* _Path,
size_t _BufferCount
);

 char Outpath[_MAX_PATH] = { 0 };
_fullpath(Outpath, "hello.txt", _MAX_PATH);

 

posted @ 2020-10-20 16:33  Monday1024  阅读(175)  评论(0)    收藏  举报