Error in program
Hello people
I'm beggining programming in C, well now I have problems with the following program:
#include <stdio.h>
main()
{
int c, i, letter[26];
FILE *fp, *fopen();
fp = fopen("chapter1", "r");
for (i = 0; i < 26; ++i) /* initialize array to cero */
letter[i] = 0;
while ((c = getc(fp)) != EOF)
if ('A' <= c && c <= 'Z')
++letter [c - 'A'];
for (i = 0; i < 26; ++i)
{
if (i % 6 == 0)
printf ("\n");
printf ("%5c:%5d", 'A' + 1, letter[i]);
}
printf ("\n\n");
}
When I compilled it no erros, no warnings, but when I excecuted, says: "Segmentation fault"
Can anyone help me to solve this problem??? I hope so.
Regards
dludenar
|