summaryrefslogtreecommitdiffstats
path: root/man3/scanf.3
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:40:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:40:15 +0000
commit399644e47874bff147afb19c89228901ac39340e (patch)
tree1c4c0b733f4c16b5783b41bebb19194a9ef62ad1 /man3/scanf.3
parentInitial commit. (diff)
downloadmanpages-399644e47874bff147afb19c89228901ac39340e.tar.xz
manpages-399644e47874bff147afb19c89228901ac39340e.zip
Adding upstream version 6.05.01.upstream/6.05.01
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'man3/scanf.3')
-rw-r--r--man3/scanf.3143
1 files changed, 143 insertions, 0 deletions
diff --git a/man3/scanf.3 b/man3/scanf.3
new file mode 100644
index 0000000..7934509
--- /dev/null
+++ b/man3/scanf.3
@@ -0,0 +1,143 @@
+'\" t
+.\" Copyright 2022 Alejandro Colomar <alx@kernel.org>
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH scanf 3 2023-07-20 "Linux man-pages 6.05.01"
+.SH NAME
+scanf, fscanf, vscanf, vfscanf \- input FILE format conversion
+.SH LIBRARY
+Standard C library
+.RI ( libc ", " \-lc )
+.SH SYNOPSIS
+.nf
+.B #include <stdio.h>
+.PP
+.BI "int scanf(const char *restrict " format ", ...);"
+.BI "int fscanf(FILE *restrict " stream ,
+.BI " const char *restrict " format ", ...);"
+.PP
+.B #include <stdarg.h>
+.PP
+.BI "int vscanf(const char *restrict " format ", va_list " ap );
+.BI "int vfscanf(FILE *restrict " stream ,
+.BI " const char *restrict " format ", va_list " ap );
+.fi
+.PP
+.RS -4
+Feature Test Macro Requirements for glibc (see
+.BR feature_test_macros (7)):
+.RE
+.PP
+.BR vscanf (),
+.BR vfscanf ():
+.nf
+ _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
+.fi
+.SH DESCRIPTION
+The
+.BR scanf ()
+family of functions scans input like
+.BR sscanf (3),
+but read from a
+.IR FILE .
+It is very difficult to use these functions correctly,
+and it is preferable to read entire lines with
+.BR fgets (3)
+or
+.BR getline (3)
+and parse them later with
+.BR sscanf (3)
+or more specialized functions such as
+.BR strtol (3).
+.PP
+The
+.BR scanf ()
+function reads input from the standard input stream
+.I stdin
+and
+.BR fscanf ()
+reads input from the stream pointer
+.IR stream .
+.PP
+The
+.BR vfscanf ()
+function is analogous to
+.BR vfprintf (3)
+and reads input from the stream pointer
+.I stream
+using a variable argument list of pointers (see
+.BR stdarg (3).
+The
+.BR vscanf ()
+function is analogous to
+.BR vprintf (3)
+and reads from the standard input.
+.SH RETURN VALUE
+On success, these functions return the number of input items
+successfully matched and assigned;
+this can be fewer than provided for,
+or even zero, in the event of an early matching failure.
+.PP
+The value
+.B EOF
+is returned if the end of input is reached before either the first
+successful conversion or a matching failure occurs.
+.B EOF
+is also returned if a read error occurs,
+in which case the error indicator for the stream (see
+.BR ferror (3))
+is set, and
+.I errno
+is set to indicate the error.
+.SH ERRORS
+.TP
+.B EAGAIN
+The file descriptor underlying
+.I stream
+is marked nonblocking, and the read operation would block.
+.TP
+.B EBADF
+The file descriptor underlying
+.I stream
+is invalid, or not open for reading.
+.TP
+.B EILSEQ
+Input byte sequence does not form a valid character.
+.TP
+.B EINTR
+The read operation was interrupted by a signal; see
+.BR signal (7).
+.TP
+.B EINVAL
+Not enough arguments; or
+.I format
+is NULL.
+.TP
+.B ENOMEM
+Out of memory.
+.SH ATTRIBUTES
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lbx lb lb
+l l l.
+Interface Attribute Value
+T{
+.na
+.nh
+.BR scanf (),
+.BR fscanf (),
+.BR vscanf (),
+.BR vfscanf ()
+T} Thread safety MT-Safe locale
+.TE
+.sp 1
+.SH STANDARDS
+C11, POSIX.1-2008.
+.SH HISTORY
+C99, POSIX.1-2001.
+.SH SEE ALSO
+.BR fgets (3),
+.BR getline (3),
+.BR sscanf (3)