title: How to limit scanf while reading input from file
body: <p>I'm a beginner with C and I have coded a program like :</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main() {
  
      char r[10];
      char y[10];
      puts("Printing Data \n");
      while (scanf(" %10s %s",r,y) == 2) {
          printf("%s and %s\n",r,y);
  }
      return 0;
  }
  
  </code></pre>
  
  <p>CMD ./prog.c &lt; file.txt</p>
  
  <p>file.txt </p>
  
  <pre><code>aman dhaker
  rudra pratap hensome
  nitesh dhakar
  </code></pre>
  
  <p>While I wanted scanf to read just 2 strings but having 3 strings on line 2 of file.txt I wanted to skip the 3rd arg which was hensome as I only wish to print 2 strings but somehow I'm unable to skip particular string.</p>
  
  <p>My current output :</p>
  
  <pre><code>aman dhaker
  rudra pratap hensome
  nitesh dhakar
  </code></pre>
  
  <p>My desired output:</p>
  
  <pre><code>aman dhaker
  rudra pratap
  nitesh dhakar
  </code></pre>
  
  <p>Please help me out.</p>
  
  <p>I've tried including regex like [^ ] to exclude result including a whitespace but didn't work out.</p>