title: Read a file and write its contents to another C++
body: <p>So I'm writing a function to read a file and put its content into another file. Here's what I've got so far:</p>
  
  <pre><code>void myFile::printWords(string input, string output) {
   ifstream file(input.c_str());
   ofstream file_out(output.c_str());
   string word;
  
   if(!file.is_open())
   {
    printf("File can't be opened\n");
    exit(o);
   }
   while(file &gt;&gt; word) {
    cout&lt;&lt; word &lt;&lt; '\n';
   }
   file.close();
  
  }
  </code></pre>
  
  <p>Question is how do I proceed with writing to a file?</p>