C| how to check if my input buffer(stdin) is empty?
<p>I want to know how to check if my input buffer (perhaps its called <code>stdin</code>) is empty or not.
I dont want the program to stop if the buffer is empty, and I dont want the input to necessarily end with <code>\n</code>, therefore just using <code>scanf</code> is not enough.</p>
<p>I tried searching on google and on this website but no answer was enough.
I tried using <code>feof(stdin)</code> like this:</p>
<pre><code>int main()
{
    char c,x;
    int num;
    scanf(&quot;%c&quot;,&amp;c);
    scanf(&quot;%c&quot;,&amp;x);
    num=feof(stdin);
    printf(&quot;%d&quot;,num);
}
</code></pre>
<p>but all it did was printing 0 no matter the input. adding <code>fflush(stdin)</code> after the second scanf gave the same result.
other answers suggested using select and poll but I couldnt find any explanations for those functions.</p>
<p>Some other forum told me to use <code>getchar()</code> but I think they misunderstood my question.</p>
<p>if you suggest I use select/poll, could you please add an explanation about how to use those?</p>