On 22 Jan 2004 16:45:31 -0800,
ne*****@tokyo.com (Mantorok Redgormor)
wrote in comp.lang.c:
I have failed to find an authoritive answer on the following:
fscanf(NULL, ..);
The rest of the function arguments have been omitted.
I'm only curious as to what behavior is given when
the first argument is NULL?
I went through J.2 of the standard but it isn't listed as
undefined behavior nor implementation defined.
Anyone know where it says what type of behavior this invokes?
<quote>
7.1.4 Use of library functions
1 Each of the following statements applies unless explicitly stated
otherwise in the detailed descriptions that follow: If an argument to
a function has an invalid value (such as a value outside the domain of
the function, or a pointer outside the address space of the program,
or a null pointer, or a pointer to non-modifiable storage when the
corresponding parameter is not const-qualified) or a type (after
promotion) not expected by a function with variable number of
arguments, the behavior is undefined.
<unquote>
Since the definition of fscanf() does not specifically state that the
first argument may be a null pointer, as for example realloc() or
strtol() do, passing one results in undefined behavior.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html