在C/C++中的字符串比较函数,基本上可以分为两类:
1、大小写敏感的字符串比较函数;
2、忽略大小写的字符串比较函数;
1、大小写敏感的字符串比较函数:
int strcmp( const char *s1, const char *s2 );
int strncmp( const char *s1, const char *s2 );
返回值: s1 > s2 return > 0;
s1 == s2 return 0;
s1 < s2 return < 0;
英文解释: strcmp() and strncmp() return an integer less than, equal to, or greater than zero if s1 is found to be less than, or match, or be greater than s2;
2、忽略大小写的字符串比较函数( compare two string ignoring case):
int strcasecmp( const char *s1, const char *s2 );
int strncasecmp( const char *s1, const char *s2 );
返回值: s1 > s2 return > 0;
s1 == s2 return 0;
s1 < s2 return < 0;
英文解释:strcasecmp() and strncasecmp() return an integer less than , equal to , or greater than zero if s1 is found to be less than, to match, or to be greater than s2;