What is the proper way to do user input in C?
Here is my problem. When I do a scanf("%10s", buffer); if the user types more than 10 characters the remaining characters on stdin will be used for the next call to scanf. This is also the case when using getchar(). This is very annoying because I don't want the input from the first input prompt to override input for the second input prompt. Is there a way to clear the stdin stream so that another read from stdin doesn't use the remaining data on stdin?
Thanks,
-bitwise
Here is my problem. When I do a scanf("%10s", buffer); if the user types more than 10 characters the remaining characters on stdin will be used for the next call to scanf. This is also the case when using getchar(). This is very annoying because I don't want the input from the first input prompt to override input for the second input prompt. Is there a way to clear the stdin stream so that another read from stdin doesn't use the remaining data on stdin?
Thanks,
-bitwise