The difference between string.h and strings.h

I noticed that there was (at least on Mac OS X) a string.h header and a strings.h header. man 3 string shows that they contain different functions. Is there a reason for this?

+76
c string header
Nov 27 '10 at 10:22
source share
2 answers

strings.h comes from the BSD branch in unix evolution. Its content was standardized by POSIX, but most of it is marked as a legacy and can be easily replaced with other functions:

 int bcmp(const void *, const void *, size_t); /* LEGACY, see memcmp */ void bcopy(const void *, void *, size_t); /* LEGACY, see memcpy, memmove */ void bzero(void *, size_t); /* LEGACY, see memset */ int ffs(int); char *index(const char *, int); /* LEGACY, see strchr */ char *rindex(const char *, int); /* LEGACY, see strrchr */ int strcasecmp(const char *, const char *); int strncasecmp(const char *, const char *, size_t); 
+92
Nov 27 2018-10-11T00:
source share

Typically, <strings.h> simply adds some useful, but non-standard optional string functions to the standard <string.h> header. For maximum portability, you should use only <string.h> , but if you need functions in <strings.h> more than you need portability, you can use <strings.h> instead of <string.h> .

+14
Nov 27 '10 at
source share



All Articles