The scanf function, which is found in C, reads input for numbers and other datatypes from standard input (often a command line interface or similar kind of a text user interface). The following shows code in C that reads a variable number of unformatted decimal integers from the standard input stream and prints out each of them on a separate line. In C programming, printf and scanf are commonly used functions to display output and take input from users.
Scanf, scanfl, wscanf, wscanfl. 2 minutes to read.In this articleReads formatted data from the standard input stream. More secure versions of these function are available; see. Syntax int scanf(const char.format ,argument.);int scanfl(const char.format,localet locale ,argument.);int wscanf(const wchart.format ,argument.);int wscanfl(const wchart.format,localet locale ,argument.);ParametersformatFormat control string.argumentOptional arguments.localeThe locale to use. Return ValueReturns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned.If format is a NULL pointer, the invalid parameter handler is invoked, as described in.
If execution is allowed to continue, these functions return EOF and set errno to EINVAL.For information on these and other error codes, see. RemarksThe scanf function reads data from the standard input stream stdin and writes the data into the location given by argument.
Each argument must be a pointer to a variable of a type that corresponds to a type specifier in format. If copying takes place between strings that overlap, the behavior is undefined.