ah one more ...
the next 29 char will not lead to another "scanf" ... so it'd be safer.
for more info : fflush (stdin) -could cleanup all the input data that have been entered to prevent from the next char input.
reason : '\n' is char - so scanf will detect the char and then detect again ... <sorry language not really good enough>
that mean you can't enter the data on the next char variable (variable >> input2)
input2 = '\n'
here is your data on the input2
>Is using scanf in this way dangerous?
What happens if the user enters 30 characters before a newline? The array is filled with characters and there's no room for a nul terminator. Since scanf doesn't place the \0 after a read, this can and should cause problems with functions that rely on the nul being there.
>for more info : fflush (stdin) -could cleanup all the input data
>that have been entered to prevent from the next char input.
No, fflush is not defined for input streams, so fflush ( stdin ) invokes undefined behavior. To clear the stream after a call to scanf, a loop would be best:
while ( getchar() != '\n' );
or for more thorough checking:
>that mean you can't enter the data on the next char variable
void ifflush ( FILE *fp )
while ( ( c = getc ( fp ) ) != EOF && c != '\n' );
Correct, calls to scanf tend to leave the newline in the stream buffer. This causes problems when you try to perform another read. Yet another reason to avoid scanf when possible.