[Solved] How to use fflush in c on OS/X [closed]
Calling fflush(stdin); invokes undefined behavior. You should not use this to flush characters from the standard input buffer. Instead, you can read the characters upto the next linefeed and ignore them: int c; while ((c = getchar()) != EOF && c != ‘\n’) continue; You can also use scanf() for this, but it is tricky: … Read more