strncmp函数的使用

来源:互联网 发布:塑料卡扣连接技术 淘宝 编辑:程序博客网 时间:2024/05/19 00:47

这个函数用来比较s1和s2字符串的前maxlen个字符。如果两个字符串相等的话,strncmp将返回0。如果s1是s2的一个子串的话,s1小于s2。此外还有,函数 int strncmp (const char *s1, const char *s2, size_t size) 此函数与strcmp极为类似。不同之处是,strncmp函数是指定比较size个字符。也就是说,如果字符串s1与s2的前size个字符相同,函数返回值为0。

nt strncmp ( const char * str1, const char * str2, size_t num );

0 0