title: Check if stdin pipe is empty in C
body: <p>I am using user input to fill a 2d array. A user inputs numbers in one line and I then use nested loops to fill the array like so:</p>
  
  <pre><code>//User inputs: "1 2 3 4 5"
  
  for(i = 0; i &lt; r; i++){
      for(j = 0; j &lt; c; j++){
              scanf("%d", &amp;arr[i][j]);
      }
   }
  </code></pre>
  
  <p>However, the problem is if the user enters 5 ints when there is room for 6, it just waits for another input. How can I detect if there are insufficient numbers?</p>
  
  <p>I have tried using this but it didn't work:</p>
  
  <pre><code>for(i = 0; i &lt; r; i++){
      for(j = 0; j &lt; c; j++){
          if (!feof(stdin)){
              scanf("%d", &amp;arr[i][j]);
          }
          else{
              printf("insufficient datapoints\n");
          }
      }
   }
  </code></pre>