The Wayback Machine - https://web.archive.org/web/20240121132526/https://www.geeksforgeeks.org/strcmpi-function-in-c/
Open In App
Related Articles

strcmpi() function in C

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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 than the length of str2 and if the length of str1 is greater than 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




// 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




// 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

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 02 Feb, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads