[Methinks this belongs to the forum devoted to C and C++. I do not see posts made here all to often.]
Some suggestions to the OP:
Avoid doing I/O in C. If you are learning the language, you could simply hard-code your inputs. If you are in a professional environment, you will very likely be using a good library for I/O.Avoid using scanf. If you have to read input in C, use getchar instead.Absolutely do NOT give a finite sized stack allocated array to be assigned a value from scanf. Lookup BUFFER OVERFLOW on Google. Think of what could happen if the user were to provide a line as input that is longer than 49 characters in length. (Yes, you could specify in your format string to scanf, a length of your input -- but before you respond like so, see above point.)Get into habit of examining a function's return value. In your particular example, scanf's return value would have provided you with very valuable information.
To answer your question --
The scanf's format specifier says "Keep reading all input until you encounter a newline, and store the result in the ith element of name." When scanf reads the input, it encounters the newline the first time.
It leaves this newline in the input stream. As a result the newline is not consumed, and hence it is encountered in the second and the third time of your loop. The other lines of input is simply waiting to be read.
hope this helps,
- Anand
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery