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)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章