title: How do I create an array of ifstream objects and how can I populate that array with numbered text files?
body: <p>I have a bunch of text files in a directory, and each text file is named "info1.txt", "info2.txt" and so on. How would I open up all of the text files in an array of ifstream objects without having to hard-code all my text file names in? I know the following code does not work, but I think it conveys the idea of what I want to do if it did work:</p>
  
  <pre><code>ifstream myFiles[5];
  for(int i = 0; i &lt; 5; i++){
      myFiles[i].open("info" + i + ".txt");
  }
  </code></pre>
  
  <p>I know the solution is probably very simple, but after a lot of research, trial and error I still haven't figured it out. Thanks!</p>