Scanf


Description

Scanf stands for "scan formatted" is an built-in function defined in stdio.h header file that scans the input entered by the user and stores into the variable specified.

Syntax

Scanf("format specifiers", arguments);

Similar to printf, scanf format specifiers argument determines how many arguments are there and are of what data types. Argument is the list of variable names starting with '&' sign and separated by commas.

Eg: scanf("%d%d", &a,&b);

In the above example it scans two variables of integer data types and stores the value into a and b variable. Where &a and &b are the pointers pointing to the memory location to store the value, if pointers are not declared it will store the value in wrong memory location as compiler doesn't detects the error at compile time.

The input value of two variables must be standard input entered by separating blank space or by entering on a new line by the user.