title: opening a txt file twice c++
body: <p>In my program I am trying to read a file of numbers. I would like to take the first number and make that number the size of my array. After closing the file, I would like to reopen the same file and store the rest of the numbers into the array. In the array, I would like to sort the numbers using the bubble sort algorithm and display the array in ascending order.</p>
  
  <pre><code>int readData(int * arr);
  void bsort(int * arr, int last);
  void writeToConsole(int * arr, int last);
  void swap(int, int);
  int main()
  {
     ifstream inFile("data.txt");
     int arrSize;
     inFile &gt;&gt; arrSize;
     int * arr = new int[arrSize];
     inFile.close();
     readData(arr);
     writeToConsole(arr, arrSize);
     system("pause");
     return 0;
  }
  int readData(int * arr)
  {
     ifstream read("data.txt");
     int index = 0;
     for(int i = 0; i &lt; 10; i++)
     {
         read &gt;&gt; *(arr + index);
         index++;
     }
     read.close();
     return *arr;
  }
  void bsort(int * arr, int last)
  {
      for (int i = last - 1; i &gt;= 0; i--)
      {
          for (int j = 1; j &lt;= i; j++)
          {
              //this block is constant with respect to array size
              if (*(arr + (j - 1)) &gt; *(arr + j))
              {
                  int temp = *(arr + (j - 1));
                  *(arr + (j - 1)) = *(arr + j);
                  *(arr + j) = temp;
              }
          }
      }
  }
  void writeToConsole(int * arr, int last)
  {
      bsort(arr, last);
      for (int i = 0; i &lt; last; i++)
      {
          cout &lt;&lt; *(arr + i) &lt;&lt; " ";
      }
  }
  void swap(int x, int  y)
  {
      int temp = x;
      x = y;
      y = temp;
  }
  </code></pre>
  
  <p>In other words, the first time I read the file, the number that is stored will represent the size of my array. The second time I read the file, I want to skip the first number and proceed to the next one. When reading a file, how can I skip the first number? Any help would be greatly appreciated.</p>
  
  <p>Here is the information from the file I would like to read:</p>
  
  <pre><code>9
  
  8
  
  4
  
  7
  
  2
  
  9
  
  5
  
  6
  
  1
  
  3
  </code></pre>