/* Program to illustrate global file references and open() method */ #include #include #include using namespace std; //function prototypes void change(string &str); //global declarations ifstream infile; ofstream outfile; int main() { string line; // open input file infile.open("c:\\bc\\CISC1110\\pgms\\chapter8\\myinput.txt"); //comment-out for debugging //infile.open("con"); //un-comment for debugging // open output file //outfile.open("c:\\bc\\CISc1110\\pgms\\chapter8\\myoutput.txt"); //comment-out for debugging outfile.open("con"); //un-comment for debugging while (getline(infile, line)) { change(line); outfile << line << endl; } infile.close(); //close input file outfile.close(); //close output file // system("pause"); //un-comment when using DevC++ return 0; } void change(string &str) { str += 's'; return; }