scanf allows formatted reading of data from the keyboard. Like printf it has a control string, followed by the list of items to be read. However scanf wants to know the address of the items to be read, since it is a function which will change that value. Therefore the names of variables are preceeded by the & sign. Character strings are an exception to this. Since a string is already a character pointer, we give the names of string variables unmodified by a leading &.
Control string entries which match values to be read are preceeded by the percentage sign in a similar way to their printf equivalents.
Type man scanf for details of all options on your system.
Go to printf Go to Index Go to Whole I/O