Last modified on 18 October 2011, at 20:28

C Programming/C Reference/string.h/stricmp

Prototype of stricmp function is

#include<string.h>
int stricmp( char *str1, char *str2 );

stricmp(str1,str2) compares str1 and str2 lexicographically without regards to case . It returns a negative value if str1<str2; 0 if str1 and str2 are identical; and positive value if str1>str2.

Example:

#include  <stdio.h>
#include  <conio.h>
int main()
{
    char str1[]="c proGrAmMing"; 
    char str2[]="C PROGRAMMIG"; 
    int i;        
    clrscr();
    i=stricmp(str1,str2);
    if(i==0)       
        printf("\nstr1 and str2 are identical");
    else if(i<0)     
        printf("\n\nstr1< str2");
    else
        printf("\n\nstr1< str2");
    getch();
    return 0;
}

ReferencesEdit