SOURCE FILE: copier.cpp


/*
   Program to read a file and copy all the strings to another file.
   Files: copyIn   - input file of characters 
          copyOut - output file that is a list of the strings from copyIn
*/

#include <fstream>
#include <string>

using namespace std ;

int main(void)
{
   void CopyStrings(ofstream&, ifstream&);
   
   ifstream infile("copyIn");

   ofstream outfile("copyOut");
   
   CopyStrings(outfile, infile);

   return 0;
}

/*
   Function to copy an input file to an output file,
   writing the strings one per line.
   Pre:  outfile is an ofstream output file stream.
         infile is an ifstream input file stream.
   Post: The strings in the input file have been copied to the output file,
	 one string per line.
*/  

void CopyStrings(ofstream& outfile, ifstream& infile)
{
   string nextStr; /* string to read and write */
    
   while (infile >> nextStr)
   {
     outfile << nextStr << endl ;
   }
}