Hello,
I've got this kind of problem, where I want to change a word inside of a text file.
apparently, I can use the char to change the character, however, it can't changes any word or sentence, so can any one help me out. much appreciated.
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cctype>
using namespace std;
int main(){
ifstream fin;
ofstream fout;
fin.open("rect.svg");
if (fin.fail()){
cout << "open failed!";
exit(1);
}
fout.open("rect1.svg");
if (fout.fail()){
cout << "save failed!";
exit(1);
}
char next, key;
cin >> key;
do {
fin >> next;
if (next == '2')
fout << '0';
else
fout << next;
}while (!fin.eof());
fin.close();
fout.close();
cout << "end of the program.";
cin.ignore(1000, '\n'); // clear out any additional input from the stream
cin.get();
return 0;
}