红联Linux门户
Linux帮助

linux 下c函数strcmp的返回值疑问?

发布时间:2009-08-24 09:59:55来源:红联作者:yang__guo
linux 下c函数strcmp的返回值疑问?
strcmp函数解释:
NAME
strcmp, strncmp - compare two strings

SYNOPSIS
#include

int strcmp(const char *s1, const char *s2);

int strncmp(const char *s1, const char *s2, size_t n);

DESCRIPTION
The strcmp() function compares the two strings s1 and s2. It returns an integer less than, equal to, or greater than
zero if s1 is found, respectively, to be less than, to match, or be greater than s2.

The strncmp() function is similar, except it only compares the first (at most) n characters of s1 and s2.

RETURN VALUE
The strcmp() and strncmp() functions return an integer less than, equal to, or greater than zero if s1 (or the first n
bytes thereof) is found, respectively, to be less than, to match, or be greater than s2.

CONFORMING TO
SVr4, 4.3BSD, C89, C99.

SEE ALSO
bcmp(3), memcmp(3), strcasecmp(3), strcoll(3), strncasecmp(3), wcscmp(3), wcsncmp(3)

返回值是整型,那么,当第一个参数const char *s1是空指针,即为NULL时,返回值应该是多少啊?
我等于NULL,结果编译时,报:warning: comparison between pointer and integer
难道等于什么?????


请高手赐教,谢谢!!
文章评论

共有 4 条评论

  1. liyilulihua 于 2011-02-23 10:21:44发表:

    [i=s] 本帖最后由 liyilulihua 于 2011-2-24 11:43 编辑 [/i]

    此问题已得到解决,

  2. yang__guo 于 2009-08-26 11:52:23发表:

    急,在线等

    谢谢!

  3. yang__guo 于 2009-08-24 14:39:57发表:

    急,在线等

    谢谢!

  4. yang__guo 于 2009-08-24 14:09:43发表:

    自己顶一下