Like printf, scanf requires a format string as its first parameter and will then expect a list of parameters, one for each format specifier embedded in this string. These parameters should be pointers to variables of the required type, given in the same order. The formats specified are the same as those for printf, %d, %c etc. Thus, each format string defines a pattern that will be looked for in the input stream. If a match for this pattern is found, the value of the item matching each format specifier will be stored in the required internal form in the variable pointed to by the matching parameter.
Thus the program
#include <stdio.h> void main() { int i1; char c1; float f1; char s1[6]; scanf("int %d char %c float %f string %s\n", &i1, &c1, &f1, s1); }will input the line
int 3 char e float 3.4 string yesand store the value 3 in i1, 'e' in c1, 3.4 in f1 and "yes" in s1. Plain text to compile.