string.h和strings.h的区别

转载自:http://blog.csdn.net/xin_yu_xin/article/details/38672137

strings.h头文件是从BSD系UNIX系统继承而来,里面定义了一些字符串函数,如bzero等。这些函数曾经是posix标准的一部分,但是在POSIX.1-2001标准里面,这些函数被标记为了遗留函数而不推荐使用。在POSIX.1-2008标准里已经没有这些函数了。如下:

int  bcmp( const  void  *,  const  void  *,  size_t );  /* 用memcmp替代 */
void  bcopy( const  void  *,  void  *,  size_t );  /* 用memcpy, memmove替代 */
void  bzero( void  *,  size_t );  /* 用memset替代 */
int  ffs( int );  /* string.h 中有 */
char  *index( const  char  *,  int );  /* 用strchr替代 */
char  *rindex( const  char  *,  int );  /* 用strrchr替代 */
int  strcasecmp( const  char  *,  const  char  *);  /* string.h 中有 */
int  strncasecmp( const  char  *,  const  char  *,  size_t );  /* string.h 中有 */

这两个头文件都在linux的/usr/include目录下面,后者比前者多了一个s,一般使用以string.h(没有s)的为主,那strings.h(有s)什么时候使用呢?打开这个头文件,可以看见区别如下:
/* We don't need and should not read this file if <string.h> was already
read. The one exception being that if __USE_BSD isn't defined, then
these aren't defined in string.h, so we need to define them here. */
所以,一般使用前者就可以了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值