title: C++ read text file into an array
body: <p>I'm trying to read a text file containing 20 names into an array of strings, and then print each string to the screen.</p>
  
  <pre><code>string monsters[20];
  ifstream inData;
  inData.open("names.txt");
  for (int i=0;i&lt;monsters-&gt;size();i++){
      inData &gt;&gt; monsters[i];
      cout &lt;&lt; monsters[i] &lt;&lt; endl;
  }inData.close();
  </code></pre>
  
  <p>However when I run this code the loop is executed but nothing is read into the array. Where have I gone wrong?</p>