The difference between strcmp and stricmp, Strcmpi (c + +)

Source: Internet
Author: User
Tags strcmp

#include <string.h> #include <stdio.h>   prototypes: extern int strcmp (const void *S1, const void *S2);   Usage: #include <string.h>  function: Compare strings S1 and S2 are the same, case-sensitive.   NOTE: If S1=s2 returns zero, it returns a value other than 0.    prototype: extern int stricmp (char *s1,char * s2);         usage: #include <string.h>  function: Compares strings S1 and S2, but does not distinguish between uppercase and lowercase letters.   Description: Strcmpi is a macro definition to stricmp, this function is not actually provided.          when S1&LT;S2, return value <0          When S1=S2, the return value =0         when S1&GT;S2, the return value >0  //an example:  void Main () {char *str1= "I am Oldwolf"; char *str2= "I am Oldwolf"; int cmp; printf ("original string: N%sn%snn", STR1,STR2); CMP =STRCMP (STR1,STR2); if (cmp!=0)    printf ("strcmp comparison string is not the same!) n "); else   printf (" strcmp Compare string Same! n "); cmp=stricmp (STR1,STR2); if (cmp!=0)    printf (" stricmp comparison string is not the same!) n "); else   printf (" stricmp Compare string Same! n "); cmp=sTrcmpi (STR1,STR2); if (cmp!=0)    printf ("Strcmpi comparison string is not the same!) n "); else   printf (" Strcmpi Compare string Same! n ");}

Differences between strcmp and STRICMP, Strcmpi (c + +)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.