ExamVeda
Login
Home
C plus plus miscellaneous
?

How are many number of characters available in newname.txt?
#include <stdio.h>
int main ()
{
    FILE * p;
    int n = 0;
    p = fopen ("newname.txt", "rb");
    if (p == NULL) 
        perror ("Error opening file");
    else
    {
        while (fgetc(p) != EOF)
        {
            ++n;
        }
        if (feof(p)) 
        {
            printf ("%d\n", n);
        }
        else
            puts ("End-of-File was not reached.");
        fclose (p);
    }
    return 0;
}

Answer & Solution
Correct Answer: Option C
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.