#include #include using namespace std; int main (int argc, char *argv[]) { string filename; cout << "Enter output filename: "; cin >> filename; ofstream outfile(filename.c_str(), ios::trunc); if (!outfile.is_open()) { cout << "[Write] Unable to open " << filename; return -1; } outfile << "I hate pointers in C"; outfile.flush(); ifstream infile(filename.c_str()); if (!infile.is_open()) { cout << "[Read] Unable to open " << filename; return -1; } string line; getline( infile, line ); cout << line << endl; outfile.seekp(2); outfile << "love"; outfile.seekp(1, ios::cur); outfile << "references"; outfile.seekp(0,ios::end); outfile << "++" << endl; infile.seekg(0, ios::beg); getline( infile, line ); cout << line << endl; }