scanf()

Reads formatted input from stdin. Passes addresses of variables using the & operator.

Syntax

c
int scanf(const char *format, ...)

Example

c
int age;
char name[50];

printf("Enter your name: ");
scanf("%49s", name);

printf("Enter your age: ");
scanf("%d", &age);

printf("Hello, %s! Age: %d\n", name, age);