// version 4 - copy a file to another file #include #include #include #include main() { int ch; int count = 0; ifstream testf; testf.open("test2.C"); if (!testf.is_open()) { cerr << "can't open input file for processing!" << endl; exit(1); } ofstream testout; testout.open("testout.txt"); if (!testout) { cerr << "Cannot open output file" << endl; exit(1); } while ( (ch= testf.get()) !=EOF) { testout.put((char)ch); count++; } testout.close(); cout <<"end of processing - copied " << count << " characters" << endl; }