title: C++ writing to file error in Linux/Ubuntu?
body: <p>I have been trying to learn C++ recently, but I have stumbled across some errors. For example, when I try to run this code to ask the user what they want outputted to a file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  
  using namespace std;
  
      main() {
          string output; //Declare variables before starting
          FILE * file = fopen("newfile.txt","w"); //creates file
          cout &lt;&lt; "Entire something that you want to be written to the file: " &lt;&lt; endl;
          cin.getline(output, 256);  //Asks what you want to put into file
          fprintf(file, output); //Puts output into file
          fclose(file);   //closes file
          return 0;
      }
  </code></pre>
  
  <p>using</p>
  
  <pre><code>g++ -o main test.cpp
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>test.cpp: In function ‘int main()’:
  test.cpp:10:25: error: no matching function for call to ‘std::basic_istream&lt;char&gt;::getline(std::string&amp;, int)’
    cin.getline(output, 256);
                           ^
  test.cpp:10:25: note: candidates are:
  In file included from /usr/include/c++/4.8/iostream:40:0,
                   from test.cpp:1:
  /usr/include/c++/4.8/istream:618:5: note: std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::basic_istream&lt;_CharT, _Traits&gt;::getline(std::basic_istream&lt;_CharT, _Traits&gt;::char_type*, std::streamsize, std::basic_istream&lt;_CharT, _Traits&gt;::char_type) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_istream&lt;_CharT, _Traits&gt;::char_type = char; std::streamsize = long int]
       basic_istream&lt;char&gt;::
       ^
  /usr/include/c++/4.8/istream:618:5: note:   candidate expects 3 arguments, 2 provided
  /usr/include/c++/4.8/istream:427:7: note: std::basic_istream&lt;_CharT, _Traits&gt;::__istream_type&amp; std::basic_istream&lt;_CharT, _Traits&gt;::getline(std::basic_istream&lt;_CharT, _Traits&gt;::char_type*, std::streamsize) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_istream&lt;_CharT, _Traits&gt;::__istream_type = std::basic_istream&lt;char&gt;; std::basic_istream&lt;_CharT, _Traits&gt;::char_type = char; std::streamsize = long int]
         getline(char_type* __s, streamsize __n)
         ^
  /usr/include/c++/4.8/istream:427:7: note:   no known conversion for argument 1 from ‘std::string {aka std::basic_string&lt;char&gt;}’ to ‘std::basic_istream&lt;char&gt;::char_type* {aka char*}’
  test.cpp:11:22: error: cannot convert ‘std::string {aka std::basic_string&lt;char&gt;}’ to ‘const char*’ for argument ‘2’ to ‘int fprintf(FILE*, const char*, ...)’
    fprintf(file, output);
                        ^
  </code></pre>
  
  <p>Could someone please help me? And please forgive me if this is something that can be easily solved, I am fairly new to C++ and do not quite understand it yet.</p>