text: Write your own strcmp that ignores cases |  ; implementation of strcmp that ignores cases ; If characters are same or inverting the 6 th bit makes them same ; Compare the last ( or first mismatching in case of not same ) characters ; Set the 6 th bit in both , then compare ; Driver program to test above function
code: #include <stdio.h> NEW_LINE int ic_strcmp ( char * s1 , char * s2 ) { int i ; for ( i = 0 ; s1 [ i ] && s2 [ i ] ; ++ i ) { if ( s1 [ i ] == s2 [ i ] || ( s1 [ i ] ^ 32 ) == s2 [ i ] ) continue ; else break ; } if ( s1 [ i ] == s2 [ i ] ) return 0 ; if ( ( s1 [ i ] 32 ) < ( s2 [ i ] 32 ) ) return -1 ; return 1 ; } int main ( void ) { printf ( " ret : ▁ % d STRNEWLINE " , ic_strcmp ( " Geeks " , " apple " ) ) ; printf ( " ret : ▁ % d STRNEWLINE " , ic_strcmp ( " " , " ABCD " ) ) ; printf ( " ret : ▁ % d STRNEWLINE " , ic_strcmp ( " ABCD " , " z " ) ) ; printf ( " ret : ▁ % d STRNEWLINE " , ic_strcmp ( " ABCD " , " abcdEghe " ) ) ; printf ( " ret : ▁ % d STRNEWLINE " , ic_strcmp ( " GeeksForGeeks " , " gEEksFORGeEKs " ) ) ; printf ( " ret : ▁ % d STRNEWLINE " , ic_strcmp ( " GeeksForGeeks " , " geeksForGeeks " ) ) ; return 0 ; }