Site hosted by Angelfire.com: Build your free website today!



Next: Whole Line Input Up: Input and Output Previous: Formatted Input Output

Formatted Input Output with Strings

These are the third set of the printf and scanf families. They are called sprintf and sscanf.

sprintf
puts formatted data into a string which must have sufficient space allocated for it. This might be done by declaring it as an array of char. The data is formatted according to a control string of the same form as that for printf.
sscanf
takes data from a string and stores it in other variables as specified by the control string. This is done in the same way that scanf reads input data into variables. sscanf is very useful for converting strings into numeric values.