Next: Files Up: Input and Output (I/O) Previous: Printf

scanf

This function is defined as follows:

int scanf(char *format, args....) - reads from stdin and puts input in address of variables specified in args list. Returns number of chars read.

Format control string similar to printf

Note: The ADDRESS of variable or a pointer to one is required by scanf.

scanf(``%d'',&i);

We can just give the name of an array or string to scanf since this corresponds to the start address of the array/string.


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994