How to compare strings without case sensitivity in C

2 Answers

0 votes
// Use stricmp() — to compare strings without case sensitivity

#include <stdio.h>
#include <string.h>

int main(void)
{
    char s1[15] = "c c++ java";
    char s2[15] = "C C++ JAVA";
    
    if (stricmp(s1, s2) == 0)
        printf("The strings are equal\n");
    else
        printf("The strings are not equal\n");
  
    return 0;
}

  
/*
run:
  
The strings are equal

*/

 



answered Jun 21, 2017 by avibootz
0 votes
// Use strcmpi() — to compare strings without case sensitivity

#include <stdio.h>
#include <string.h>

int main(void)
{
    char s1[] = "c c++ java";
    char s2[] = "C C++ JAVA";
    
    if (strcmpi(s1, s2) == 0)
        printf("The strings are equal\n");
    else
        printf("The strings are not equal\n");
  
    return 0;
}

  
/*
run:
  
The strings are equal

*/

 



answered Jun 22, 2017 by avibootz

Related questions

1 answer 244 views
1 answer 142 views
142 views asked Aug 23, 2024 by avibootz
1 answer 162 views
2 answers 217 views
217 views asked Oct 15, 2015 by avibootz
1 answer 177 views
3 answers 227 views
1 answer 128 views
128 views asked Sep 27, 2022 by avibootz
...