int count_digit(FILE *fp)
{
int c, cnt=0;
rewind(fp);
while (c=fgetc(fp) != EOF)
if( isdigit(c))
cnt++;
if( !feof(fp) )
cnt = -1;
return cnt;
}
The function above contains an error that prevents it from properly counting the number of digits in a file. Which one of the following describes the error?
a. The function fgetc() operates on a file descriptor not a file pointer.
b. The variable c is declared but not initialized. This is forbidden by Standard C and may have unpredictable results.
c. The inequality operator (!=) has higher precedence than assignment (=), and the loop condition is therefore incorrect.
d. There is no function rewind() that conforms to an accepted standard. The conformant function is called frewind(), and the function name has been misspelled.
e. feof() returns zero to indicate that an end-of-file condition has been encountered. The sense of the condition is therefore reversed.
{
int c, cnt=0;
rewind(fp);
while (c=fgetc(fp) != EOF)
if( isdigit(c))
cnt++;
if( !feof(fp) )
cnt = -1;
return cnt;
}
The function above contains an error that prevents it from properly counting the number of digits in a file. Which one of the following describes the error?
a. The function fgetc() operates on a file descriptor not a file pointer.
b. The variable c is declared but not initialized. This is forbidden by Standard C and may have unpredictable results.
c. The inequality operator (!=) has higher precedence than assignment (=), and the loop condition is therefore incorrect.
d. There is no function rewind() that conforms to an accepted standard. The conformant function is called frewind(), and the function name has been misspelled.
e. feof() returns zero to indicate that an end-of-file condition has been encountered. The sense of the condition is therefore reversed.