HP-UX Reference (11i v3 07/02) - 3 Library Functions A-M (vol 6)
f
fwscanf(3C) fwscanf(3C)
If a conversion specification is invalid, the behavior is undefined.
The conversion characters A, E, F
, G and X are also valid and behave the same as, respectively,
a, e, f, g
and x.
If end-of-file is encountered during input, conversion is terminated. If end-of-file occurs before any wide-
characters matching the current conversion specification (except for
%n) have been read (other than leading
white-space, where permitted), execution of the current conversion specification terminates with an input
failure. Otherwise, unless execution of the current conversion specification is terminated with a matching
failure, execution of the following conversion specification (if any) is terminated with an input failure.
Reaching the end of the string in
swscanf() is equivalent to encountering end-of-file for fwscanf() .
If conversion terminates on a conflicting input, the offending input is left unread in the input. Any trailing
white space (including newline) is left unread unless matched by a conversion specification. The success of
literal matches and suppressed assignments is only directly determinable via the
%n conversion
specification.
The
fwscanf() and wscanf() functions may mark the
st_atime field of the file associated with
stream for update. The
st_atime field will be marked for update by the first successful execution of
fgetc(), fgetwc(), fgets(), fgetws() , fread(), getc(), getwc(), getchar() ,
getwchar() , gets(), fscanf() or fwscanf() using stream that returns data not supplied by a
prior call to ungetc().
APPLICATION USAGE
After fwscanf() or wscanf() is applied to a stream, the stream becomes wide-oriented (see orienta-
tion(5)).
In format strings containing the
% form of conversion specifications, each argument in the argument list is
used exactly once.
The prototypes of these functions are available to applications if they are:
a. c99 conformant.
b. Compiled with -D_XOPEN_SOURCE
macro with a value >=500.
c. Compiled with
-D_POSIX_C_SOURCE
macro with a value >= 200112.
RETURN VALUE
Upon successful completion, these functions return the number of successfully matched and assigned input
items; this number can be 0 in the event of an early matching failure. If the input ends before the first
matching failure or conversion,
EOF is returned. If a read error occurs the error indicator for the stream
is set, EOF is returned, and errno is set to indicate the error.
ERRORS
For the conditions under which the fwscanf() functions will fail and may fail, refer to
fgetwc().In
addition,
fwscanf() may fail if:
[EILSEQ] Input byte sequence does not form a valid character.
[EINVAL] There are insufficient arguments.
[ENOMEM] Insufficient storage space is available.
In addition, fwscanf() may fail if:
[EILSEQ] The stream pointed to by stream is byte-oriented.
In addition, wscanf() may fail if:
[EILSEQ] stdin is byte-oriented.
EXAMPLES
The call:
int i, n; float x; char name[50];
n = wscanf(L"%d%f%s", &i, &x, name);
with the input line:
484 Hewlett-Packard Company − 4 − HP-UX 11i Version 3: February 2007