博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2014年9月8日

摘要: 1.strtok()函数的用法函数原型:char *strtok(char *s, const char *delim);Function:分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。Description:strtok()用来将字符串分割成一个个片段。参数s指向欲分割的字... 阅读全文

posted @ 2014-09-08 23:06 猫少侠 阅读(689) 评论(0) 推荐(0) 编辑

摘要: 0.两者比较: memmove用于从src拷贝count个字符到dest,如果目标区域和源区域有重叠的话,memmove能够保证源串在被覆盖之前将重叠区域的字节拷贝到目标区域中。但复制后src内容会被更改。但是当目标区域与源区域没有重叠则和memcpy函数功能相同。 memmove在copy两个... 阅读全文

posted @ 2014-09-08 20:23 猫少侠 阅读(934) 评论(0) 推荐(0) 编辑

摘要: 首先看看代码: 1 #ifndef STRCAT_H 2 #define STRCAT_H 3 4 /******************************************************************* 5 原型:extern char *strcat(char ... 阅读全文

posted @ 2014-09-08 14:03 猫少侠 阅读(2449) 评论(0) 推荐(0) 编辑

摘要: strlen: 1 #ifndef STRLEN_H 2 #define STRLEN_H 3 4 #include 5 6 // 参考微软的写法 7 int cat_strlen(const char *str) { 8 const char *p = str; 9 10 ... 阅读全文

posted @ 2014-09-08 11:17 猫少侠 阅读(236) 评论(0) 推荐(0) 编辑

摘要: 注意转化为unsigned char:strcmp.h 1 #ifndef STRCMP_H 2 #define STRCMP_H 3 4 /*************************************************** 5 功能:比较字符串s1和s2。 6 一般形式:s... 阅读全文

posted @ 2014-09-08 10:46 猫少侠 阅读(1191) 评论(0) 推荐(0) 编辑

摘要: strcpy.h: 1 #ifndef STRCPY_H 2 #define STRCPY_H 3 4 #include 5 6 char *cat_strcpy(char *dst, const char *src) { 7 if (NULL == src || NULL == sr... 阅读全文

posted @ 2014-09-08 10:19 猫少侠 阅读(1884) 评论(0) 推荐(0) 编辑

摘要: 字符串查找算法中,最著名的两个是KMP算法(Knuth-Morris-Pratt)和BM算法(Boyer-Moore)。两个算法在最坏情况下均具有线性的查找时间。但是在实用上,KMP算法并不比最简单的c库函数strstr()快多少,而BM算法则往往比KMP算法快上3-5倍。但是BM算法还不是最快... 阅读全文

posted @ 2014-09-08 00:48 猫少侠 阅读(1054) 评论(0) 推荐(0) 编辑