The scanf function is in the <stdio.h> header file. It is used to read data from the standard input device and store it in the specified variable. The format specifier specifies the format of the input data, and a variable number of parameter lists represent the addresses of variables where the data is to be stored.
#scanf is in which header file?
scanf function is in the <stdio.h>
header file.
Detailed description:
<stdio.h>
The header file contains the declaration of the standard input/output library functions. The scanf function is used to read data from the standard input device (usually the keyboard) and store it in a specified variable.
The prototype of the scanf function is as follows:
<code class="cpp">int scanf(const char *format, ...);</code>
Among them:
format
: a format specifier string that specifies the format of the input data . ...
: A variable number of parameter lists, each parameter represents a variable to store data. For example, the following code uses the scanf function to read an integer and a floating point number from the keyboard:
<code class="cpp">#include <stdio.h> int main() { int i; float f; scanf("%d %f", &i, &f); printf("整数:%d\n浮点数:%f\n", i, f); return 0; }</code>
In the above code, the format specifier of the scanf function is "%d % f" specifies to read an integer (%d) and a floating point number (%f). &i and &f are the addresses of variables used to store the input data in the i and f variables.
The above is the detailed content of In which header file is scanf in c++. For more information, please follow other related articles on the PHP Chinese website!