title: How do I print out the contents of a file? C++ File Stream
body: <p>I am using fstream and C++ and all I want my program to do is to print out to the terminal the contents of my .txt file. It may be simple, but I have looked at many things on the web and I can't find anything that will help me. How can I do this? Here is the code I have so far:</p>
  
  <pre><code>    #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main() {
      string output;
      ifstream myfile;
      ofstream myfile2;
  
      string STRING;
      myfile.open ("/Volumes/LFARLEIGH/Lucas.txt");
  
      myfile2 &lt;&lt; "Lucas, It Worked";
  
          myfile &gt;&gt; STRING;
          cout &lt;&lt; STRING &lt;&lt; endl;
      myfile.close();
  
  
      return 0;
  }
  </code></pre>
  
  <p>Thank you in advance. Please forgive me if this is very simple as I quite new to C++</p>