Chinaunix首页 | 论坛 | 博客
  • 博客访问: 315403
  • 博文数量: 69
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 759
  • 用 户 组: 普通用户
  • 注册时间: 2014-09-09 14:15
个人简介

〆 人生就是拼命地奔跑,和华丽的跌倒。 つ

文章分类

全部博文(69)

文章存档

2017年(2)

2016年(16)

2015年(21)

2014年(30)

分类: C/C++

2015-05-05 21:25:08

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) 

例:

点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <string.h>

  3. int main()
  4. {
  5.     char s1[10];
  6.     char s2[10];
  7.     
  8.     int result;

  9.     scanf("%s%s", &s1, &s2);

  10.     result=strcmp(s1, s2);
  11.     //result=strncmp(s1, s2, 6);
  12.     
  13.     printf("result is :%d\n", result);

  14.     return 0;
  15. }


阅读(2146) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~