i am having trouble with this c language code:
char st[2];
printf("enter first value:");
scanf("%c", &st[0]);
printf("enter second value:");
scanf("%c", &st[1]);
So my computer didn't ask me to enter the second value, I mean to say that it only print the first printf
statement then I enter a character and then it only prints the second printf
statement and program end without taking the second input.
Please help. What's wrong with this code?
-Thanks in advance.
Well it did. The character(s) produced by the ENTER key is present in the buffer already.
I think your problem is the second scanf is receiving the "Enter" key press.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With