title: Why does this code turn back blank console while trying to put a .txt into a vector and cout it?
body: <p>I am trying to open a .txt using a void function named ‘scan’ and a vector called ‘lines' but the console keeps returning blank. The same code ran perfectly on Windows but not on Mac (both with Codeblocks). What went possibly wrong? The .txt file is in the same folder as the whole project.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt; 
  #include &lt;vector&gt;
  using namespace std;
  
  void scan(vector&lt;string&gt; &amp;lines)
  {
      ifstream fin("mytext.txt"); 
      string str;
  
      while(!fin.eof())
      {
          getline(fin, str); 
          lines.push_back(str); 
      }
  }
  
  
  
  int main()
  {
      vector &lt;string&gt; lines;
      scan(lines); 
  
      for(int i=0; i&lt;lines.size(); i++)
      {
          cout&lt;&lt;lines[i]&lt;&lt;endl;
      }
  }
  </code></pre>