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;
}
Answer: Option
Explanation:
Extra parameter in call to fclose().
Discussion:
27 comments Page 1 of 3.
Snegha m d said:
1 year ago
The correct answer is D.
Pratyush sharma said:
3 years ago
Option D will be the Right answer because you can not pass more than one argument in function.
(1)
Rajan said:
5 years ago
@All.
The code should be;
#include<stdio.h>
int main ()
{
FILE *fs, *ft, *fp;
fp = fopen("ABC", "r");
fs = fopen("ACD", "r");
ft = fopen("ADF", "r"); = fclose(fp, fs, ft);
return 0;
}
A - "ABC"
B- "ACD"
The code should be;
#include<stdio.h>
int main ()
{
FILE *fs, *ft, *fp;
fp = fopen("ABC", "r");
fs = fopen("ACD", "r");
ft = fopen("ADF", "r"); = fclose(fp, fs, ft);
return 0;
}
A - "ABC"
B- "ACD"
Venkat said:
7 years ago
Please explain it in a simple way.
Pranathi said:
8 years ago
'fclose()' takes only one argument at a time i.e it can't be used to close multiple opened file at a time.
(3)
Yuvasree said:
9 years ago
Yes, correct answer is D, It will get error message as too many arguments to function fclose. Because according fclose syntax we can pass only one argument.
Vivek Shivhare said:
10 years ago
Yes it is true to write "return (a, b, c)" it will returns the right most value (e.g c).
The reason is return and fclose both are predefined functions theirs properties are designed by devlopers. Which are different.
fclose is file operation function so it is different than return.
The reason is return and fclose both are predefined functions theirs properties are designed by devlopers. Which are different.
fclose is file operation function so it is different than return.
(1)
Kumar harsh said:
1 decade ago
Can any body tell when fclose (a, b, s) is false then is it true return (a, b, c)?
Please tell me in detail.
Please tell me in detail.
K Srinivas Pavan Kumar said:
1 decade ago
We can close any number of files by using a function fcloseall().
Anu said:
1 decade ago
Please explain then how to print fp fs ft?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers