STRCMP(3) Linux Programmer’s Manual STRCMP(3)
NAME
strcmp, strncmp - compare two strings
//strcmp,strncmp -比较两个字符串
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.
//strcmp()函数比较s1和s2两个字符串.如果s1成立,它返回一个整数,小于,
等于,或大于0。分别和s2比较,匹配大小。
The strncmp() function is similar, except it only compares the first
(at most) n characters of s1 and s2.
//strncmp()函数很小,它仅仅(至少)比较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.
//如果s1成立(或者其中的n个字节)strcmp()函数和strncmp()函数返回一个整数,
小于,等于,或大于0.分别和s2比较,匹配大小。
CONFORMING TO
SVr4, 4.3BSD, C89, C99.
SEE ALSO
bcmp(3), memcmp(3), strcasecmp(3), strcoll(3), strncasecmp(3), strver-
scmp(3), wcscmp(3), wcsncmp(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at
//这篇是linux3.22版本手册项目中的一部分,一个项目的描述,还有关于漏洞
信息的报告,能够在中查找。
2009-04-21 STRCMP(3)
(END)
例:
-
#include <stdio.h>
-
#include <string.h>
-
-
int main()
-
{
-
char s1[10];
-
char s2[10];
-
-
int result;
-
-
scanf("%s%s", &s1, &s2);
-
-
result=strcmp(s1, s2);
-
//result=strncmp(s1, s2, 6);
-
-
printf("result is :%d\n", result);
-
-
return 0;
-
}
阅读(2209) | 评论(0) | 转发(0) |