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 3 of 3.
Vanita said:
1 decade ago
How? can you explain it clearly?
Silome jain said:
1 decade ago
Please tell about all file function, why we use it, what its purpuse to use.
Cheran said:
1 decade ago
Because we cannot give many parameters inside fclose().
Apurva Nigam said:
1 decade ago
Inbuilt function fclose has a prototype fclose(FILE *stream) that is it can have only one parameter passed to it.
Take a simple example:-
u have a function "func(int);".
Now u cant call this function as
func();
or
func(i,j,k);
Function call should match with its prototype...
Take care :)
Take a simple example:-
u have a function "func(int);".
Now u cant call this function as
func();
or
func(i,j,k);
Function call should match with its prototype...
Take care :)
Gayathri said:
1 decade ago
The correct option is D only.
because the syntax of fclose is int fclose(FILE *stream); and we cannot use separator(,) in this.
if you use separator it will return an error as Extra parameter in call to fclose().
because the syntax of fclose is int fclose(FILE *stream); and we cannot use separator(,) in this.
if you use separator it will return an error as Extra parameter in call to fclose().
Riya said:
1 decade ago
Please tell the correct answer (C) or (D). ?
Bhanu Prakash said:
1 decade ago
The the correct option is C. "A.C"
there can be any no. of arguments passed to fclose.
But which file is closes depends on the functionality of the comma(,) operator. It takes the first argument.
there can be any no. of arguments passed to fclose.
But which file is closes depends on the functionality of the comma(,) operator. It takes the first argument.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers