title: Read File in Loop C++
body: <p>I have a function: </p>
  
  <pre><code>void ReadInput(const char * name)
  {
      ifstream file(name);
      cout &lt;&lt; "read file " &lt;&lt; name &lt;&lt; endl;
      size_t A0, A1, A2;
      file &gt;&gt; A0 &gt;&gt; A1 &gt;&gt; A2;
  }
  </code></pre>
  
  <p>Now i want to read two files: INPUT1.txt and INPUT2.txt in a loop, such as:</p>
  
  <pre><code>int main ()
  {
      for (int i = 1; i &lt; 3; i++){
          ReadInput(INPUT$i);
      }
      return 0;    
  }
  </code></pre>
  
  <p>The question is how do i define the loop correctly. </p>
  
  <p>Thanks for your time in advance. </p>
  
  <p>Here is the whole code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  
  
  using namespace std;
  
  
  void ReadInput(const string&amp; _name){
      ifstream file(_name);
      size_t A0, A1, A2;
      file &gt;&gt; A0 &gt;&gt; A1 &gt;&gt; A2;
  }
  
  
  int main ()
  {
  
  
      for (int i = 1; i &lt; 3; ++i) {
          string file_name = "INPUT" + to_string(i) + ".txt";
          ReadInput(file_name);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>OK, all good, now i can compile in c++98 by converting string to const char and stringstream instead of to_string. My goal was to run an automated program with input files all in the same directory. The suggestions about possible duplicate of the question does not achieve that as i have to pass on the input file number as i execute, as i understand it, which is impractical for 3,000 something files. </p>