title: C programming warning: array subscript has type 'char' [-Wchar-subscripts]
body: <p>I can't seem to fix this problem. Below is my code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;ctype.h&gt;
  #include&lt;string.h&gt;
  
  _Bool are_anagrams (const char *word1, const char *word2);
  
  int main (void)
  {
      char an1[30], an2[30];
      int j;
      printf("Enter first word: ");
      scanf("%s", an1);
      printf("Enter second word: ");
      scanf("%s", an2);
      printf("The words are");
  
      j = are_anagrams (an1, an2);
  
      if (j == 0)
      {
          printf(" not anagrams. \n");
      }else
          printf(" anagrams. \n");
  
      return 0;
  }
  
  _Bool are_anagrams (const char *word1, const char *word2)
  {
      int i;
      int check[26] = {0};
      for(i=0; i&lt;30; i++)
          if(word1[i] == '\0')
              i=40;
          else
          {
              word1[i] = toupper(word1[i]);
              check[word1[i]-65]++;
          }
  
      for(i=0; i&lt;30; i++)
          if(word2[i] == '\0')
              i=40;
          else
          {
              word2[i] = toupper(word2[i]);
              check[word2[i]-65]--;
          }
  
      for(i=0; i&lt;26; i++)
          if(check[i] != 0)
          {
              return 0;
          }
  
      return 1;
  }
  </code></pre>
  
  <p>these are the error messages:</p>
  
  <pre class="lang-none prettyprint-override"><code>anagram1.c:38:3: warning: array subscript has type ‘char’ [-Wchar-subscripts]
     word1[i] = toupper(word1[i]);
     ^
  anagram1.c:38:3: error: assignment of read-only location ‘*(word1 + (sizetype)((long unsigned int)i * 1ul))’
  anagram1.c:46:4: warning: array subscript has type ‘char’ [-Wchar-subscripts]
      word2[i] = toupper(word2[i]);
      ^
  anagram1.c:46:4: error: assignment of read-only location ‘*(word2 + (sizetype)((long unsigned int)i * 1ul))’
  </code></pre>