.\" Add ERRORS section.
.\" Document the 'a' and 'm' modifiers for dynamic string allocation.
.\"
-.TH SCANF 3 2013-01-30 "GNU" "Linux Programmer's Manual"
+.TH SCANF 3 2014-01-11 "GNU" "Linux Programmer's Manual"
.SH NAME
scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- input format conversion
.SH SYNOPSIS
and assigns the address of this buffer to the corresponding
.I pointer
argument, which should be a pointer to a
-.I "char *"
+.I "char\ *"
variable (this variable does not need to be initialized before the call).
The caller should subsequently
.BR free (3)
If
.I format
contains \(aq%\(aq
-specifications then these correspond in order with successive
+specifications, then these correspond in order with successive
.I pointer
arguments.
In the
If used with
.B %c
or
-.B %s
+.BR %s ,
the corresponding parameter is considered
as a pointer to a wide character or wide-character string respectively.
.\" This use of l was introduced in Amendment 1 to ISO C90.
.I maximum field width
(default 1); the next pointer must be a pointer to
.IR char ,
-and there must be enough room for all the characters (no terminating
-null byte
-is added).
+and there must be enough room for all the characters
+(no terminating null byte is added).
The usual skip of leading white space is suppressed.
To skip white space first, use an explicit space in the format.
.TP
.I libc (glibc-1.08)
for a more concise description.
.SH NOTES
-The GNU C library supported the dynamic allocation conversion specifier
+.SS The 'a' assignment-allocation modifier
+Originally, the GNU C library supported dynamic allocation for string inputs
(as a nonstandard extension) via the
.B a
-character. This feature
-seems to be present at least as far back as glibc 2.0.
+character.
+(This feature is present at least as far back as glibc 2.0.)
+Thus, one could write the following to have
+.BR scanf ()
+allocate a buffer for an input string,
+with a pointer to that buffer being returned in
+.IR *buf :
+
+ char *buf;
+ scanf("%as", &buf);
+.PP
+The use of the letter
+.B a
+for this purpose was problematic, since
+.B a
+is also specified by the ISO C standard as a synonym for
+.B f
+(floating-point input).
+POSIX.1-2008 instead specifies the
+.B m
+modifier for assignment allocation (as documented in DESCRIPTION, above).
.PP
-It is not available if the program is compiled with
+Note that the
+.B a
+modifier is not available if the program is compiled with
.I "gcc -std=c99"
or
.IR "gcc -D_ISOC99_SOURCE"
.B a
is interpreted as a specifier for floating-point numbers (see above).
-Since version 2.7, glibc also provides the
+Support for the
.B m
-modifier for the same purpose as the
-.BR a
-modifier.
-The
+modifier was added to glibc starting with version 2.7,
+and new programs should use that modifier instead of
+.BR a .
+
+As well as being standardized by POSIX, the
.B m
-modifier has the following advantages:
+modifier has the following further advantages over
+the use of
+.BR a:
.IP * 2
It may also be applied to
.B %c
.B %a
floating-point conversion specifier (and is unaffected by
.IR "gcc -std=c99"
-etc.)
-.IP *
-It is specified in the POSIX.1-2008 standard.
+etc.).
.SH BUGS
All functions are fully C89 conformant, but provide the
additional specifiers
.BR strtod (3),
.BR strtol (3),
.BR strtoul (3)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.