title: How to switch scanf input to standard terminal input after reading input through input redirection
body: <p>I need to have my program read several words from a .txt file and store them into an array using the scanf() function. However, I need to accept user input after that also using scanf. How do I ensure that scanf only accepts user input after all the words are read?</p>
  
  <p>I have tried using scanf() and getchar() to accept whitespace at the end of the file in case that is what scanf is reading at the point where I need user input. </p>
  
  <pre><code>char w[15][100];
  for(int i =0;i&lt;15;i++)
  {
  
      if(scanf("%s", &amp;w[i][0])=1)
      {
          scanf("%s", &amp;w[i][0]);
      }
      getchar();
      printf("Word read\n");
  }
   bool validAnswer2=false;
      while(validAnswer2==false) 
      {
          printf("Would you like to play again?\nType \"y\" to play again or \"n\" to exit: ");
          scanf(" %c", &amp;reply);
          getchar();
          if(reply=='y')
          {
              validAnswer2=true;
          }
          else if(reply=='n')
          {
              validAnswer2=true;
  
          }
  
      }
  </code></pre>
  
  <p>When the program reaches the point where scanf needs to accepts user input rather than file input, I have designed it to check if the input is a letter and try scanf again if it is not. The program infinitely tries scanf, each time getting invalid input. I am redirecting input by using nameOfFile &lt; words.txt where words.txt is a file with 15 words.</p>