I need help in finding out the problem with my code.
I have displayed here parts of the code for clarification.
int acount = 0,count=0,i=0, j = 0, c, letter;
//here i am opening a file for writing
outfile = fopen("c:\\nasser\\cprograms\\tout.txt","w");
if (outfile == NULL)
printf("Cannot find output file");
// some process
// a bunch of capital letters written here
// eg. THIS IS A TEST TO COUNT THE NUMBER OF OCCURENCES OF EACH LETTER
//initializing array letter to zeros
for (j = 0; j < 26; ++j)
letter[j] = 0;
//reading outfile, and assigning a number of occurences of each letter
while ((c = getc(outfile)) != EOF)
++letter[c - 'A'];
Everything works the way I wanted until I got to this statement
// printing out the array letter.
for (i = 0; i < 26; i++)
I was expecting freq of occurrences of each letter here but I get a bunch of 26 zeros.
I am definitely doing something wrong, but not quite sure what it is.
Any help would be appreciated.
Thanks in advance.