title: Reading an text file into an array of strings
body: <p>I have a text file that contains several words, all separated by spaces. I'm trying to read the file and then put it into an array, so that each word is a separate value in said array. I'm using this code, but when I run my program, it doesn't display anything (like it should.)</p>
  
  <pre><code>ifstream file ("words.txt");
  if(file.is_open())
  {
  string wordArray[100];
  for(int i = 0; i &lt; 100; ++i)
  {
      file &gt;&gt; wordArray[i];
      cout &lt;&lt; i;
  }
  cout &lt;&lt; "File is open.";
  }
  </code></pre>
  
  <p>Nothing displays at all. I'm doing this in a void function, which isn't being passed anything currently, but I don't think that has anything to do with it. The code should at least display "File is open" or any number from 1 to 100, but I don't get anything. I don't understand why this isn't working, as I'm including iostream, string, fstream, iomanip, and sstream. If there's something simple I'm overlooking, please let me know.</p>