This is a general problem of the keyboard buffer. When scanf("%d",&n); is used and when an input is entered, the newline character("n") along with the input is stored in buffer. This buffer gets clear as the user presses "Enter" or if the buffer is full.
So when we use the scanf("%d",&n); the "n" is left in the buffer itself. So the buffer will fill the string with "
Why scanf("%d",&n) and gets(string) don't work together?
Profile Answers by pbchaudhari Questions by pbchaudhari
Questions by pbchaudhari answers by pbchaudhari