Re: C Interview Questions
- From: Richard Heathfield <invalid@xxxxxxxxxxxxxxx>
- Date: Tue, 31 Oct 2006 06:34:44 +0000
Adrian said:
Richard Heathfield wrote:
dhruvaraj@xxxxxxxxx said:
6. .Identify the correct argument for the function call fflush() in ANSI
C:
None of the candidate answers is uniquely correct. Three are wrong, and
stdout is only /one/ correct argument for fflush.
Richard, could you tell me why all three are wrong.
Um, make that two. :-) (And neither of the other two is uniquely correct,
so it's still a big deal from a getting-the-right-answer perspective.)
While there isn't much point in fflushing stderr, it's legal. But fflush is
only well-defined for streams open for update or output, which stdin is
not. So the answer cannot be A, because that would suggest C is wrong,
cannot be B because it's wrong, cannot be C because that would suggest A is
wrong, and cannot be D because B is wrong.
Also the standard says you can pass NULL to fflush to flush all open
streams.
Indeed, which is another reason that there is no such thing as *the* correct
argument to fflush.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.
- Follow-Ups:
- Re: C Interview Questions
- From: Simon Biber
- Re: C Interview Questions
- References:
- C Interview Questions
- From: dhruvaraj
- Re: C Interview Questions
- From: Richard Heathfield
- Re: C Interview Questions
- From: Adrian
- C Interview Questions
- Prev by Date: Re: Out-of-bounds Restrictions?
- Next by Date: Re: C Interview Questions
- Previous by thread: Re: C Interview Questions
- Next by thread: Re: C Interview Questions
- Index(es):
Relevant Pages
|
|