/* 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\\cis1_5\\newpgms\\chapter8\\myinput.txt"); //comment-out for debugging // infile.open("con"); //un-comment for debugging // open output file // outfile.open("c:\\bc\\cis1_5\\newpgms\\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"); return 0; } void change(string &str) { str += 's'; return; }