iOS training------My C language notes, look forward to communicating with you!
#include <stdio.h>intMain () {//define a variable to hold the integer entered by the user intNumber ; //the scanf function accepts only the address of the variable//The scanf function is a blocking function that waits for the user to enter//after the user has entered, the value entered by the user is assigned to the number variable//function call Completescanf"%d", &Number ); printf ("the value entered by the user is%d\n", number); return 0;}/*prompts the user to enter two integers, calculates and outputs two integers and*/Example: #include<stdio.h>intMain () {//1. Define 2 variables to save the integer entered by the user intNum1, num2; //2. Prompt the user to enter a 1th integerprintf"Please enter a 1th integer: \ n"); //3. Receive the 1th integer entered by the userscanf"%d", &NUM1); //4. Prompt the user to enter a 2nd integerprintf"Please enter a 2nd integer: \ n"); //5. Receive the 2nd integer entered by the userscanf"%d", &num2); //6. Calculate and, and output intsum = NUM1 +num2; printf ("%d+%d=%d\n", NUM1, num2, sum); return 0;}
"Good Programmer's note sharing" Basic use of the scanf function of C language