字符串比较函数使用
strcmp()函数
- 比较字符串(区分大小写)
#include <string.h>
int strcmp(const char *s1, const char *s2);
- 若s1与s2相同,则返回0;
- 若s1大于s2,则返回大于0的值;
- 若s1小于s2,则返回小于0的值;
strcasecmp()函数
- 比较字符串(不区分大小写)
#include <string.h>
int strcasecmp(const char *s1, const char *s2);
- 返回值结果,与上述相同;
strncasecmp()函数
- 比较前n个字符串(不区分大小写)
#include <string.h>
int strncasecmp(const char *s1, const char *s2, size_t n);
- 返回值结果,与上述相同;