strcmpi() function in C
The strcmpi() function is a built-in function in C and is defined in the “string.h” header file. The strcmpi() function is same as that of the strcmp() function but the only difference is that strcmpi() function is not case sensitive and on the other hand strcmp() function is the case sensitive.
Syntax:
int strcmpi (const char * str1, const char * str2 );
Parameters:
- str1: The first string.
- str2: The second string.
Returns: This function returns 0 if the given two strings are same, a negative value if the length of str1 is less then the length of str2 and if the length of str1 is greater then str2 then this function returns a positive value.
Note: This is a non-standard function that works only with older versions of Microsoft C.
Below programs illustrate the strcmpi() function in C:
Program 1:
// C program to demonstrate // example of strcmpi() function #include <stdio.h> #include <string.h> int main( ) { char str1[] = "geeks" ; char str2[] = "geeks" ; int j = strcmpi ( str1, str2 ) ; printf ( "The function returns = %d",j ) ; return 0; } |
Output:
The function returns = 0
Program 2:
// C program to demonstrate // example of strcmpi() function #include <stdio.h> #include <string.h> int main( ) { char str1[ ] = "geeks" ; char str2[ ] = "ForGeeks" ; int i = strcmpi ( str1, str2 ) ; printf ( "The function returns = %d", i ) ; return 0; } |
Output:
The function returns = 1
Recommended Posts:
- arc function in C
- strrev() function in C
- iswspace() function in C/C++
- iswdigit() function in C/C++
- strtod() function in C/C++
- towlower() function in C/C++
- iswxdigit() function in C/C++
- strcspn() function in C/C++
- wcstoll() function in C/C++
- iswalnum() function in C++ STL
- iswblank() function in C/C++
- iswpunct() function in C/C++
- gmtime() Function in C/C++
- ldexp() function in C/C++
- atexit() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



