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 337 views
1 answer 247 views
2 answers 333 views
333 views asked Oct 15, 2015 by avibootz
1 answer 233 views
233 views asked Aug 23, 2024 by avibootz
1 answer 253 views
3 answers 378 views
1 answer 216 views
...