_splitpath函数使用
来源:互联网 发布:ch340g驱动软件下载 编辑:程序博客网 时间:2024/05/16 13:38
_splitpath
需要的头文件是:<stdlib.h>
函数原型如下:
后面四个参数分别代表四个需要从原始文件路径中截取的字符串,有驱动器盘符(drive),中间的路径(dir),文件名(fname),和后缀名(ext)。
只要在这四个参数中传入对应的字符串指针,函数返回时即可获取对应截取的字符串,不想获取的可以直接填入NULL进行忽略,比如我只想截取文件的后缀名,那么这个函数可以如下调用:
_splitpath(path, NULL, NULL, NULL, ext);
需要的头文件是:<stdlib.h>
函数原型如下:
void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext);
后面四个参数分别代表四个需要从原始文件路径中截取的字符串,有驱动器盘符(drive),中间的路径(dir),文件名(fname),和后缀名(ext)。
只要在这四个参数中传入对应的字符串指针,函数返回时即可获取对应截取的字符串,不想获取的可以直接填入NULL进行忽略,比如我只想截取文件的后缀名,那么这个函数可以如下调用:
_splitpath(path, NULL, NULL, NULL, ext);
其中ext必须是已经分配了内存空间的字符串指针,否则会出错(c语言的基本特性,我就不赘述了)
下面再附上一段完整的示例程序,供大家参考:
#include <stdlib.h> #include <stdio.h> void main( void ) { char path_buffer[_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _makepath( path_buffer, "c", "\\sample\\crt\\", "makepath", "c" ); printf( "Path created with _makepath: %s\n\n", path_buffer ); _splitpath( path_buffer, drive, dir, fname, ext ); printf( "Path extracted with _splitpath:\n" ); printf( " Drive: %s\n", drive ); printf( " Dir: %s\n", dir ); printf( " Filename: %s\n", fname ); printf( " Ext: %s\n", ext ); }OutPut:Path created with _makepath: c:\sample\crt\makepath.c Path extracted with _splitpath: Drive: c: Dir: \sample\crt\ Filename: makepath Ext: .c
0 0
- _splitpath函数使用
- _makepath 和_splitpath函数的使用
- _splitpath 或_wsplitpath函数的使用
- 分割文件名 _splitpath() 函数
- 函数_splitpath用法
- 分割文件名 _splitpath() 函数
- [转]分割文件名 _splitpath() 函数
- 分析路径参数函数_splitpath
- 分割文件名 _splitpath() 函数讲解
- _splitpath函数 具体作用看代码
- _splitpath函数得到文件的目录名和路径
- 路径参数函数:路径的获取(GetModuleFileName)和拆分(_splitpath)
- 分割文件路径函数 _splitpath()和生成文件路径函数_makepath()
- 用_splitpath 函数可以分解出路径,文件名,扩展名,msdn的例子
- 在linux系统下,简单实现类似windows的_splitpath函数的功能
- windows 上的 _splitpath 函数在 linux 平台下的简单实现
- _splitpath,_makepath分析路径
- _splitpath,_makepath分析路径
- 优化数据页面(13)——突出最佳值
- 浅析C#中的Attribute
- zookeeper学习-2-zookeeper的常用命令
- 【C/C++】Linux下system()函数引发的错误
- 指针 常量
- _splitpath函数使用
- thinkphp 去掉URL 里面的index.php
- 数据可视化-Treemap
- 给基于对话框的MFC程序添加状态栏并实时显示时间
- linux下rtnetlink answers file exists的解决方案
- Effective C++笔记 条款18
- PHP与Mysql的连接
- Bugzilla安装过程
- mysql数据库查询find_in_set('3', field)