C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - General Questions (Q.No. 6)
6.
Which files will get closed through the fclose() in the following program?
#include<stdio.h>

int main()
{
    FILE *fs, *ft, *fp;
    fp = fopen("A.C", "r");
    fs = fopen("B.C", "r");
    ft = fopen("C.C", "r");
    fclose(fp, fs, ft);
    return 0;
}
"A.C" "B.C" "C.C"
"B.C" "C.C"
"A.C"
Error in fclose()
Answer: Option
Explanation:

Extra parameter in call to fclose().

Discussion:
27 comments Page 3 of 3.

K Srinivas Pavan Kumar said:   1 decade ago
We can close any number of files by using a function fcloseall().

Cheran said:   1 decade ago
Because we cannot give many parameters inside fclose().

Riya said:   1 decade ago
Please tell the correct answer (C) or (D). ?

Anu said:   1 decade ago
Please explain then how to print fp fs ft?

Venkat said:   7 years ago
Please explain it in a simple way.

Vanita said:   1 decade ago
How? can you explain it clearly?

Snegha m d said:   1 year ago
The correct answer is D.


Post your comments here:

Your comments will be displayed after verification.