strcmp 函数 man 手册翻译

STRCMP(3)                        Linux Programmer's Manual                        STRCMP(3)

NAME
       strcmp, strncmp - compare two strings		//比较两个字符串

SYNOPSIS
       #include <string.h>

       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.
	   /*strcmp() 函数是用于比较两个字符串 s1 和 s2。函数的返回值是一个 int 类型值,如果 s1 小于 s2 返回负值,如果 s1 等于 s2 返回 0,如果 s1 大于 s2 返回整数。*/

       The strncmp() function is similar, except it compares only the first (at most) n bytes of s1 and s2.
	   /*strncmp 函数和 strcmp 函数相似,不过该函数只比较 s1 和 s2 前面最多 n 个字节*/

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.
	   /*strcmp() 和 strncmp() 函数的返回值是一个 int 类型值,如果 s1 小于 s2 返回负值,如果 s1 等于 s2 返回 0,如果 s1 大于 s2 返回整数。*/
	   /******************************   Note   ******************************/
	   /**实际操作中当 s1 > s2 时返回 1,s1 = s2,返回 0,s1 < s2 返回 -1**/
	   /**只能比较字符串,不能比较字符,否则报段错误**/
	   /**s1 和 s2 均不能为 NULL,否则报段错误**/

ATTRIBUTES
       For an explanation of the terms used in this section, see attributes(7).

       ┌────────────────────┬───────────────┬─────────┐
       │Interface           │ Attribute     │ Value   │
       ├────────────────────┼───────────────┼─────────┤
       │strcmp(), strncmp() │ Thread safety │ MT-Safe │
       └────────────────────┴───────────────┴─────────┘
CONFORMING TO
       POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.

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

COLOPHON
       This page is part of release 4.04 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this  page, can be found at http://www.kernel.org/doc/man-pages/.

                                         2015-08-08                               STRCMP(3)

猜你喜欢

转载自blog.csdn.net/wenfei11471/article/details/80702908