>>After that I would loop over a call to fgetc until I reached EOF and if I see that certain character, increment a counter.
how do i do that?
this is what i have:
Code:
int main ()
{
char ch[1]; /* User defined character */
char filename[50]; /* User defined filename */
int num = 0; /* Number of times character was found */
FILE *inp; /* pointer to input file */
printf("Enter the name of the file you wish to open: ");
scanf ("%s", filename);
inp = fopen(filename, "r");
if (inp != NULL){
printf("\nFILE OPEN");
}else{
printf("\nNOT OPEN");
getch();
exit(1);
}
printf("\n\nEnter character you wish to find: ");
scanf ("%s", &ch);
getch();
return 0;
}