Inputting Multiple Values
http://irc.essex.ac.uk/www.iota-six.co.uk/c/c2_printf_and_scanf.asp
Inputting Multiple Values
If you have multiple format specifiers within the string argument of scanf, you can input multiple values. All you need to do is to separate each format specifier with a DELIMITER - a string that separates variables. For convenience, the delimiter should be one character that's a punctuation mark, like a comma or a space. As a default, scanf stops reading in a value when space, tab or Enter is pressed.
Consider scanf("%d %d", &x, &y);
(Assume that x and y have been declared beforehand!).
If I entered: 1 2 and pressed Enter, 1 would get assigned to x, and 2 would get assigned to y.
But if I entered 1, 2 and pressed Enter, x would equal 1, but y won't get assigned 2 because scanf was not expecting a comma in the input string.
Now consider:
scanf("%d, %d, %d", &x,&y,&z);
If I entered 1 2 3 and pressed enter 1 would get assigned to x but 2 and 3 won't get assigned to y or z, simply because I didn't separate the numbers with commas.
Entering 1,2,3 works, but why does 1, 2, 3 also work? scanf ignores spaces, tabs and carriage returns immediately after the delimiters.
Just don't put a space, tab or carriage return before the delimiter! 1 ,2, 3 won't work.
If you want the user to press return after each number, try something along the lines as:
scanf("%d\n%d\n%d", &x,&y,&z);
Note that you shouldn't put a delimiter after the last format specifier!