I have the question that was asked here.
The top answer had two recommendations, and one of them (which was presented as slightly more reliable) was to use setbuf(stdin, NULL);
. However, the setbuf()
function is deprecated, and the replacement function is setvbuf()
. I am unsure how to use the parameters for this new function in a way that replicates the old function; how do I do this?
Background: when I use getchar()
in a loop, the second iteration of the loop always reads the '\n' character next, and I want to get rid of that.