#include #include void inOut(ofstream&); // function prototype int main() { const int MAXCHARS = 21; char fname[MAXCHARS] = "list.dat"; // here is the file we are working with ofstream outFile; outFile.open(fname); if (outFile.fail()) // check for a successful open { cout << "\nThe output file " << fname << " was not successfully opened" << endl; exit(1); } inOut(outFile); // call the function return 0; } void inOut(ofstream& fileOut) { const int LINELEN = 80; // longest length of a line of text const int NUMLINES = 5; // number of lines of text int count; char line[LINELEN]; // enough storage for one line of text cout << "Please enter five lines of text:" << endl; for (count = 0; count < NUMLINES; count++) { cin.getline(line,LINELEN,'\n'); fileOut << line << endl; } return; }