Flushing stdin after every input - which approach is not buggy?
问题 After Mark Lakata pointed out that the garbage isn't properly defined in my question I came up with this. I'll keep this updated to avoid confusions. I am trying to get a function that I can call before a prompt for user input like printf("Enter your choice:); followed a scanf and be sure that only the things entered after the prompt would be scanned in by scanf as valid input. As far as I can understand the function that is needed is something that flushes standard input completely. That is