0
 1.   arr[] = "stack is a data type";
 2.   char word[] = "Stack";
 3.   
 4.   for(i = 0; i<10; i++){
 5.      
 6.      if(arr[i] == word[0]){
 7.          
 8.          // here i have some codes
 9.          -------
10.           -------
11.        }
12.    }

This is a part of a program I have created. I have a string array called word. in this time it contains word "Stack". in line 6 I have a if condition statement. word[0] is upper case 'S'. but if arr[i] = 's' (lower case 's') , this condition will false because of case sensitivity. I wanna make this condition true even arr[i] = 's'.

How can i do this?

**I am using c language*

Appreciate your answers and suggestions. Thank you.

  • Does this answer your question? [Case Insensitive String comp in C](https://stackoverflow.com/questions/5820810/case-insensitive-string-comp-in-c) – InUser Jun 08 '20 at 08:14

1 Answers1

0

You can compare both by converting them to lowercase/uppercase

    if(tolower(arr[i]) == tolower(word[0])){

       // here i have some codes
       -------
       -------
    }
Shubham Khatri
  • 270,417
  • 55
  • 406
  • 400