\字符串操作函数积累

1088阅读 0评论2009-04-16 hhtr001
分类:LINUX

这几天在处理文本,用到了一些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<--------------------------*/

 
上一篇:[转]Linux 内核使用的 GNU C 扩展
下一篇:【转】Linux内核中读写文件数据的方法