Hi, Im trying to write a code from an input file that has advice about programing, then adds the exisiting content and the new content to an output file. I believe my function calls, using get, are incorrect but not sure how to correct them or which one I should use. Any help would be greatly appreciated.
When you add or edit a reply, wrap any code inside [code.][/code.] (without the .), or alternatively select / highlight all the code and hit the button <> next to B, I, U, etc..
#include <iostream>
#include <fstream>
#include <string>
int main()
{
// open ouptput file; truncate it if it exists, create it if it doesn't
std::ofstream output( "output.txt" ) ;
// copy the contents of input file to output
if( output << std::ifstream( "input.txt" ).rdbuf() )
{
// if successfull, append lines entered by the user to output
std::cout << "enter additional lines to be appended (eof when done)\n" ;
std::string line ;
while( std::getline( std::cin, line ) ) output << line << '\n' ;
}
else std::cerr << "failed to copy input file to output\n" ;
}