1. _wsplitpath_s()
_wsplitpath_s()函数:函数功能:分割路径为 — 磁盘符,路径,文件名, 文件名后缀 四部分。例子:c:/user/you/test.docCstring strFullPath = _T(“c:/user/you/test.doc”);TCHAR drive[_MAX_DRIVE];TCHAR dir[_MAX_DIR];TCHAR fname[_MAX_FNAME];TCHAR ext[_MAX_EXT];_wsplitpath_s(strFullPath, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT);执行结果:dirve: c: Dir: /user/you/ Fname: test Ext: .doc构造一个路径可以使用函数:_wmakepath_s().2. _tcslen()
_tcslen()函数:函数功能:获取字符串的长度。例子:CString strFilename = _T(“c:/user/you/test.doc”);SIZE_T nLen = _tcslen(strFilename); // nLen = 20 更安全的版本:size_t wcsnlen_s( const wchar_t *str, size_t numberOfE````emen.);p3_makepath_s()
_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; errno_t err; err = _makepath_s( path_buffer, _MAX_PATH, "c","//sample//crt//","crt_makepath_s", "c" );新闻热点
疑难解答