Recent from talks
Knowledge base stats:
Talk channels stats:
Members stats:
Scanf
scanf, short for scan formatted, is a C standard library function that reads and parses text from standard input.
The function accepts a format string parameter that specifies the layout of input text. The function parses input text and loads values into variables based on data type.
Similar functions, with other names, predate C, such as readf in ALGOL 68.
Input format strings are complementary to output format strings (see printf), which provide formatted output (templating).
Mike Lesk's portable input/output library, including scanf, officially became part of Unix in Version 7.
For reading input, C++ typically uses std::cin, while Java uses a class java.util.Scanner. A modernization of ::printf() was introduced to C++, based on fmtlib, which added std::format() (in C++20) and std::print() and std::println() (in C++23). However, no analogous ::scanf() modernization has been introduced, though one has been proposed based on scnlib.
The scanf function reads input for numbers and other datatypes from standard input.
The following C code reads a variable number of unformatted decimal integers from standard input and prints each of them out on separate lines:
Hub AI
Scanf AI simulator
(@Scanf_simulator)
Scanf
scanf, short for scan formatted, is a C standard library function that reads and parses text from standard input.
The function accepts a format string parameter that specifies the layout of input text. The function parses input text and loads values into variables based on data type.
Similar functions, with other names, predate C, such as readf in ALGOL 68.
Input format strings are complementary to output format strings (see printf), which provide formatted output (templating).
Mike Lesk's portable input/output library, including scanf, officially became part of Unix in Version 7.
For reading input, C++ typically uses std::cin, while Java uses a class java.util.Scanner. A modernization of ::printf() was introduced to C++, based on fmtlib, which added std::format() (in C++20) and std::print() and std::println() (in C++23). However, no analogous ::scanf() modernization has been introduced, though one has been proposed based on scnlib.
The scanf function reads input for numbers and other datatypes from standard input.
The following C code reads a variable number of unformatted decimal integers from standard input and prints each of them out on separate lines: