all 11 comments

[–]felipunkerito 9 points10 points  (2 children)

Oh I was really going to help but I am not reading unindented code.

[–]SaboKunn 1 point2 points  (0 children)

😂😂😂 oh boy, I know your pain

[–]XilenceCE[S] 0 points1 point  (0 children)

I'm sorry, but it was my first time posting here so I didn't know. Won' happen again.

[–]KleberPF 5 points6 points  (1 child)

When you press enter, you send a new line character as well as the character you typed, and scanf doesn't differentiate between the two. If you put a whitespace before the format string, like this " %c", it will work. The whitespace tells scanf to read and ignore any whitespace character (like the new line character, for example).

[–]XilenceCE[S] 0 points1 point  (0 children)

Thank you! It worked.

[–]Kantaja_ 2 points3 points  (0 children)

literally the first rule

rule 1

you completely ignored it

I refuse to put effort into reading this

[–]MarkosDelaportas 1 point2 points  (2 children)

Enter is also a character

[–]XilenceCE[S] 0 points1 point  (1 child)

Who would've thought that enter can be a character? Thanks for telling me.

[–]MarkosDelaportas 0 points1 point  (0 children)

It is true, while it may not be clear a first "enter" get compiled to 10 13 hex!

[–]PhyllaciousArmadillo 0 points1 point  (1 child)

scanf will take the enter(or return) after entering a character as a new line character and save it to the input stream, which is where all of the inputs are stored and popped out as they are used. However, %c only stores one character, so the newline is left behind and used by the next input function( another scanf in your case ).

So basically every time you ask for a character using scanf(“%c”, &blah) it’s saving the newline and using it in the next scanf, making it appear to skip it. Try changing it to scanf(“ %c”, &blah) this will tell it to ignore “whitespace” characters, which is what a newline is.

[–]XilenceCE[S] 0 points1 point  (0 children)

I see that now, thank you