scanf ignoring, infinite loop

When you enter something that isn’t a number, scanf will fail and will leave those characters on the input. So if you enter hello, scanf will see the h, reject it as not valid for a decimal number, and leave it on the input. The next time through the loop, scanf will see the h … Read more

Endless loop in C/C++ [closed]

The problem with asking this question is that you’ll get so many subjective answers that simply state “I prefer this…”. Instead of making such pointless statements, I’ll try to answer this question with facts and references, rather than personal opinions. Through experience, we can probably start by excluding the do-while alternatives (and the goto), as … Read more