The scanf function is an input function in C language used to read formatted data from standard input. Usage is as follows: Specify the format of the input data (using a format string). Provide the variable address (using the & operator). Reads data from standard input according to a formatted string and stores it in the specified variable.
The meaning of scanf function in C language
The scanf function is a standard input function in C language. Use Used to read formatted data from standard input (usually the keyboard) and store it in a specified memory location.
Usage:
scanf("formatted string", & variable list);
Among them:
Example:
<code class="c">int age; float weight; scanf("%d %f", &age, &weight);</code>
In this example, the scanf function reads two data from the standard input. The first data is an integer and is stored in age variable, the second data is a floating point number and is stored in the weight variable.
Format characters:
Format characters | Data type |
---|---|
%d | Integer |
%f | Floating point number |
%c | Character |
%s | String |
Note Matters:
The above is the detailed content of The meaning of scanf in c language. For more information, please follow other related articles on the PHP Chinese website!