title: C: Occurrence of Letters in Text file
body: <p>Program takes an input file through the command line and outputs the occurrence of each letter in the text file. Not sure where I went wrong.</p>
  
  <pre><code>int main(int argc, char *argv[]) {
      char word[1000];
      int a = 0;
      int b = 0;
      int d = 0;
      int c = 0;
      int e = 0;
      int f = 0;
      int g = 0;
      int h = 0;
      int i = 0;
      int j = 0;
      int k = 0;
      int l = 0;
      int m = 0;
      int n = 0;
      int o = 0;
      int p = 0;
      int q = 0;
      int r = 0;
      int s = 0;
      int t = 0;
      int u = 0;
      int v = 0;
      int w = 0;
      int x = 0;
      int y = 0;
      int z = 0;
  
      int other = 0;
  
      int counter, lenght;
  
      FILE *fp = fopen(argv[1], "r");
  
      fgets(word, 999, fp);
  
      lenght = 1000;
      for(counter = 0; counter &lt; lenght; counter++) {
          word[counter] = tolower(word[counter]);
          if (word[counter] == 'a') {
              a++;
          }
          else if (word[counter] == 'b') {
              b++;
          }
          else if (word[counter] == 'c') {
              c++;
          }
          else if (word[counter] == 'd') {
              d++;
          }
          else if (word[counter] == 'e') {
              e++;
          }
          else if (word[counter] == 'f') {
              f++;
          }
          else if (word[counter] == 'g') {
              g++;
          }
          else if (word[counter] == 'h') {
              h++;
          }
          else if (word[counter] == 'i') {
              i++;
          }
          else if (word[counter] == 'j') {
              j++;
          }
          else if (word[counter] == 'k') {
              k++;
          }
          else if (word[counter] == 'l') {
              l++;
          }
          else if (word[counter] == 'm') {
              m++;
          }
          else if (word[counter] == 'n') {
              n++;
          }
          else if (word[counter] == 'o') {
              o++;
          }
          else if (word[counter] == 'p') {
              p++;
          }
          else if (word[counter] == 'q') {
              q++;
          }
          else if (word[counter] == 'r') {
              r++;
          }
          else if (word[counter] == 's') {
              s++;
          }
          else if (word[counter] == 't') {
              t++;
          }
          else if (word[counter] == 'u') {
              u++;
          }
          else if (word[counter] == 'v') {
              v++;
          }
          else if (word[counter] == 'w') {
              w++;
          }
          else if (word[counter] == 'x') {
              x++;
          }
          else if (word[counter] == 'y') {
              y++;
          }
          else if (word[counter] == 'z') {
              z++;
          }
          else {
              other++;
          }
      }
      printf("\nCharacter frequency in %s", argv[1]);
      printf("\nCharacter   Count");
      printf("\na \t\t %d", a);
      printf("\nb \t\t %d", b);
      printf("\nc \t\t %d", c);
      printf("\nd \t\t %d", d);
      printf("\ne \t\t %d", e);
      printf("\nf \t\t %d", f);
      printf("\ng \t\t %d", g);
      printf("\nh \t\t %d", h);
      printf("\ni \t\t %d", i);
      printf("\nj \t\t %d", j);
      printf("\nk \t\t %d", k);
      printf("\nl \t\t %d", l);
      printf("\nm \t\t %d", m);
      printf("\nn \t\t %d", n);
      printf("\no \t\t %d", o);
      printf("\np \t\t %d", p);
      printf("\nq \t\t %d", q);
      printf("\nr \t\t %d", r);
      printf("\ns \t\t %d", s);
      printf("\nt \t\t %d", t);
      printf("\nu \t\t %d", u);
      printf("\nv \t\t %d", v);
      printf("\nw \t\t %d", w);
      printf("\nx \t\t %d", x);
      printf("\ny \t\t %d", y);
      printf("\nz \t\t %d", z);
      fclose(fp);
      return 0;
  }
  </code></pre>
  
  <p>Should output in two columns one being the letter and the next being the number of times that letter occurs</p>