+ 1
why "gets" does not take any input after "scanf" in C language ?
Here is a demo code : int main() { int a; char str[100]; scanf("%d",&a); gets(str); printf("%d",a); puts(str); } output : 2 2
4 Answers
+ 4
you need to input it on the same line, 2 "my name", works fine
+ 1
It is becasue the gets function reacts on the end of line \n of the previous multi-input.Just add \n into scanf format string just like this:
https://code.sololearn.com/cf0z68dV0fdg/?ref=app
+ 1
Thank You Highman.
The reference code you provided solved my problem.
+ 1
Thank you *Asterisk*