【C语言函数库】C语言中的string.h库常用函数
来源:互联网 发布:淘宝卖什么好呢 编辑:程序博客网 时间:2024/05/20 11:35
转载自:http://blog.sina.com.cn/s/blog_63e93a910100ir2t.html
1 复制
char* strcpy (char *s1, const char *s2);
s将字符串s2复制到s1指定的地址char* strncpy (char *s1, const char *s2, size_t len);
void* memcpy (void *s1, const void *s2, size_t len);将s2的前len个字符(字节)复制到s1中指定的地址, 不加'\0'
注:将b数组复制到a数组可写成memcpy(a,b,sizoef(b));
void* memmove (void *s1, const void *s2, size_t len);
当源单元和目的单元缓冲区交迭时使用size_t strxfrm (char *s1, const char *s1, size_t len);
根据程序当前的区域选项, 将s2的前len个字符(字节)复制到s1中指定的地址, 不加'\0'2 连接
将字符串s2连接到s1尾部
s2和s1所指内存区域不能重叠
将字符串s2的前len个字符连接到s1尾部, 不加'\0'
3 比较
比较字符串s1和s2
int memcmp (const void *s1, const void *s2, size_t len);
对s1和s2的前len个字符(字节)作比较
根据程序当前的区域选项中的LC_COLLATE, 比较字符串s1和s2
4 查找
void* memchr (const void *s, int ch, size_t len);
在s中查找给定字符(字节值)ch第一次出现的位置
char* strrchr (const char *s, int ch);
在串s中查找给定字符ch最后一次出现的位置, r表示从串尾开始char* strstr (const char *s1, const char *s2);s
在串s1中查找指定字符串s2第一次出现的位置size_t strspn (const char *s1, const char *s2);
返回s1中第一个在s2中不存在的字符的索引(find_first_not_of)size_t strcspn (const char *s1, const char *s2);
返回s1中第一个也在s2中存在的字符的索引(find_first_of)char* strpbrk (const char *s1, const char *s2);
与strcspn类似, 区别是返回指针而不是索引char* strtok (char *s1, const char *s2);
从串s1中分离出由串s2中指定的分界符分隔开的记号(token)第一次调用时s1为需分割的字串, 此后每次调用都将s1置为NULL,
每次调用strtok返回一个记号, 直到返回NULL为止
5 其他
size_t strlen (const char *s);
求字符串s的长度void* memset (void *s, int val, size_t len);
将从s开始的len个字节置为valchar* strerror (int errno);
返回指向错误信息字符串的指针- 【C语言函数库】C语言中的string.h库常用函数
- 【C语言函数库】C语言中的ctype.h.库常用函数
- C语言string.h库中的常用函数
- c/c++语言-string.h函数库
- C语言string.h常用函数总结
- C语言string.h常用函数总结
- C语言string.h常用函数总结
- C语言string.h常用函数总结
- C语言string.h中的函数
- C语言math.h中的常用函数
- 常用C语言函数库
- C语言常用函数库
- C语言time.h函数库
- C语言time.h函数库
- C语言time.h函数库
- C语言string.h中常用函数详解
- C语言string.h中常用字符函数介绍
- C语言string.h中常用字符函数介绍
- HDU1262:寻找素数对(简单数论)
- 51Nod - 1116 枚举 + 模拟
- 关于android某些手机java.lang.UnsatisfiedLinkError: No implementation found for ......的问题
- React Native自定义带返回按钮的标题栏组件
- 基于jsonp技术的单点登入案例分享二
- 【C语言函数库】C语言中的string.h库常用函数
- JavaScript常用脚本集锦6
- Android 6.0新特性
- Signals & Slots
- Data Partitioning Guidance
- C 练习实例13 - 水仙花数
- 3.1 读入一个参数
- linux安装redis
- jquery 方法