How does the C language store inputted data?
In C language, variables can be used to store input data. The scanf function can be used to read data from the standard input stream and store it in a specified variable. For example:
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num); // 从标准输入流中读取一个整数,并保存到num变量中
printf("You entered: %d\n", num);
return 0;
}
In the example above, the user inputs an integer, which is stored in the num variable using the scanf function. The inputted number is then displayed using the printf function.
It is worth noting that the scanf function takes two parameters, where the first parameter is a format string that specifies the data format to be read, and the second parameter is the address of the variable where the data will be saved.