scanf and Input
Read user input.
What scanf Does
scanf reads formatted input typed by the user. It uses the same specifiers as printf.
#include <stdio.h>
int main(void) {
int x = 0;
/* scanf("%d", &x); */
x = 5;
printf("x = %d\n", x);
return 0;
}The Address-Of Operator
scanf needs the address of a variable so it can store the value there. That is why you write &x.
#include <stdio.h>
int main(void) {
int x = 42;
int *p = &x;
printf("value via address = %d\n", *p);
return 0;
}