The prototype for the printf() is: | |
Scanf |
To grab things from input,scanf() is used. Beware though, scanf isn't greatest function that C has to offer. Some people brush off the scanf as a broken function that shouldn't be used often.
The prototype for scanf is:
| |
Last example will create a rectangle with rounded corner:
| |
| |
To read of data from the keyboard,scanf allows formatted . Like printf it has a control string,followed by the list of items to be read. However scanf wants to know the address of 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 the 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 equivalent. Looks similar to printf, but doesn't completely behave like the printf does. Take the example: | |
| |
For grabbing things from input. Beware though, scanf isn't the greatest function that C has to offer,scanf() is used.
|