#include #include using namespace std; int main() { fstream fi("donmau.txt"); fstream fo("out.txt"); while (!fi.eof()) { string line; getline(fi, line); string what, with; int i = 0, count = 0; int index_start = 0; while (i < line.size()) { if (count == 0 && line[i] == '#') { what += line[i]; count = 1; index_start = i; } else if (count == 1 && line[i] != '#') { what += line[i]; } else if (count == 1 && line[i] == '#') { what += line[i]; count = 0; cout << "Replace " << what << " with: "; getline(cin, with); line.replace(index_start, what.size(), with); what = ""; i = line.find('#')-1; } i++; } fo << line << endl; } fi.close(); fo.close(); }