title: Finding the most frequent character in a file in C
body: <p>I'm writing a function that finds the most common alphabetic character in a file. The function should ignore all characters other than alphabetic.</p>
  
  <p>At the moment I have the following:</p>
  
  <pre><code>int most_common(const char *filename)
  {
  char frequency[26];
  int ch = 0;
  
  FILE *fileHandle;
  if((fileHandle = fopen(filename, "r")) == NULL){
      return -1;
  }
  
  for (ch = 0; ch &lt; 26; ch++)
      frequency[ch] = 0;
  
  while(1){
      ch = fgetc(fileHandle);
      if (ch == EOF) break;
  
      if ('a' &lt;= ch &amp;&amp; ch  &lt;= 'z')
          frequency[ch - 'a']++;
      else if ('A' &lt;= ch &amp;&amp; ch &lt;= 'Z')
          frequency[ch - 'A']++;
  }
  
  int max = 0;
  for (int i = 1; i &lt; 26; ++i)
    if (frequency[i] &gt; frequency[max])
        max = i;
  
  return max;
  }
  </code></pre>
  
  <p>Now the function returns how many times the most frequent letter occurred, not the character itself. I'm a bit lost, as I'm not sure if that's the way this function should look like at all. Does it make sense and how possibly can I fix the problem?</p>
  
  <p>I would really appreciate your help.</p>