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.
Irresistiblegal said:
1 decade ago
The correct option id D coz..
syntax of fclose is-
#include <stdio.h>
int fclose( FILE *stream );
The function fclose() closes the given file stream, deallocating any buffers associated with that stream. fclose() returns 0 upon success, and EOF otherwise.
thats why when we give too much parameter inside fclose() it gives error-too many arguments to function 'fclose'.
syntax of fclose is-
#include <stdio.h>
int fclose( FILE *stream );
The function fclose() closes the given file stream, deallocating any buffers associated with that stream. fclose() returns 0 upon success, and EOF otherwise.
thats why when we give too much parameter inside fclose() it gives error-too many arguments to function 'fclose'.
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). ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers