Just in case new users read the help center and the famous MCVE page, it would be nice to add one more recommendation, for instance in the "Complete" section:
Make sure all information necessary to reproduce the problem is included:
Some people might be prepared to load the parts up, and actually try them to test the answer they're about to post.
The problem might not be in the part you suspect it is, but another part entirely.
What seems obvious to some, but isn't obvious to others, given the questions I read those last months, is that you shouldn't post interactive code.
Interactive code starts by (Python):
age = input("What's your age")
So depending on what you input, the rest of the code behaves differently. In that case, if OP had entered
age = 12
he/she could have avoided the infamous Python 3 "input
now returns strings" classical ultradupe issue.
The same goes for all those scanf
c questions (turning the scanf
into hardcoded assignment would sometimes just solve the issue, which was with scanf
in the first place)
I would add another part like (sorry for bad English :))
Unless it is crucial to the question, when writing your reproducer, make sure that it's not interactive. Get rid of statements asking for input, and replace them by values you're usually enter, and which trigger the problem you're witnessing
Of course that won't help newcomers who don't read the manual, but would make others realize that an interaction with the keyboard is bad in a so-called representative piece of code.
Extending the recommendation would be to advise users to hardcode the contents of their input files (unless the issue is I/O related) to avoid forcing potential answerers to create such a file on their disk (also preventing them to run/showcase the solution on some on-line platforms), but maybe that would be asking too much for the moment.
scanf()
stuff doing the wrong thing is a pretty common question type here that's rather dupe happy but the noobs who are posting the questions already know the issue is atscanf()
and don't know how to get any farther.