Chinaunix首页 | 论坛 | 博客
  • 博客访问: 188085
  • 博文数量: 45
  • 博客积分: 1456
  • 博客等级: 上尉
  • 技术积分: 535
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-21 17:47
文章分类
文章存档

2012年(1)

2009年(43)

2008年(1)

我的朋友

分类: LINUX

2009-04-16 10:51:20

这几天在处理文本,用到了一些string处理函数,有见过的,也有没见过的,统统记下来 ;-)
/*--------------------8<-------------------------
名称:
  strstr

参数:
  所要被匹配的大字符串
  子字符串

功能:
  子字符串匹配

返回:
  所匹配到的第一个子字符串的首地址

用法:
  #include
  char * strstr(const char *haystack, const char *needle);

其他资料:
  man 3 strstr
-------------------8<--------------------------*/

/*--------------------8<-------------------------
名称:
  strlen

参数:
  所要被长度测量的字符串

功能:
  测量字符串长度

返回:
  返回该字符串的长度

用法:
  #include
  size_t strlen(const char *s);

其他资料:
  man 3 strlen
-------------------8<--------------------------*/

/*--------------------8<-------------------------
名称:
  strdupa

参数:
  要操作的字符串

功能:
  创建该字符串的镜像,并紧跟着原字符串,在栈中扩展该字符串的所占空间,长度增加一倍.为gnu c扩展函数。

返回:
  返回新的字符串的首地址

用法:
  #define _GNU_SOURCE
  #include
  size_t strlen(const char *s);

  编译时,要指定包含头文件路径
gcc -I/usr/include sample.c -o sample

其他资料:
  man 3 strlen
-------------------8<--------------------------*/


/*--------------------8<-------------------------
名称:
  strlen

参数:
  所要被长度测量的字符串

功能:
  测量字符串长度

返回:
  返回该字符串的长度

用法:
  #include
  size_t strlen(const char *s);

其他资料:
  man 3 strlen
-------------------8<--------------------------*/

 
阅读(1024) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~