title: Redirecting input(text file) in C
body: <p>so I can't seem to redirect an input so that my program reads it. </p>
  
  <p>It says in the assignment that the program should NOT print anything to prompt for user input. As many numbers have to be read from stdin to test your programs, you are expected to use INPUT REDIRECTION to read the input from a file.</p>
  
  <p>I have this main function:</p>
  
  <pre><code>int main(int argc, char const *argv[])
  {
      int arr[100];
      for (int i = 0; i &lt; SIZE; i++)
      {
          values[i] = 0;
          hashMapLinear[i] = 0;             
      }
      FILE* file = fopen("file_name.txt", "r");             
      int index = 0;
      int k = 0;
      while (!feof(file))
      {
          fscanf(file, "%d", &amp;k);
          arr[index] = k;
          index++;
      }
      fclose(file);
      file = fopen("file_name.txt", "r");
      int i = 0;
      fscanf(file, "%d", &amp;i);
      float size = i;
  
      fscanf(file, "%d", &amp;i);
      int thresh_hold = i;
  
      int load_factor = size / 2;
      int j = 0;
  
      if (size &lt;= 0)
      {
              printf("\nSize of file can not be zero or negative integer:\n");
      }
      else
      {
          while (!feof(file))
          {
              if (num_keys &lt;= load_factor)
              {
                  int check_valid_input= fscanf(file, "%d", &amp;i);      
                  if (check_valid_input != 0 || check_valid_input== -1)
                  {
                      insert_into_hashtable(i, size);
                  }
                  else
                  {
                        printf("\n invalid input:\n");
                        exit(1);
                  }
              }
              else
              {
                  printf("\nError in inserting more numbers:\n");
                  exit(1);
              }
          }
          fclose(file);
          printHashMap(arr,size, thresh_hold);                  
      }
  }
  </code></pre>
  
  <p>How do I edit this main function so that it redirects seq.1 or any other text file to the C program? Any help would be appreciated!</p>