#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<S2, return value <0 When S1=S2, the return value =0 when S1>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 + +)