need to modific code

i writed this code.. but need to can chenge more 1 words.. how to do this? if i write 1 word that chenge.. but cant do 2 or more words((( help plz

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <algorithm>
using namespace std;
int main()
{
    string line;
    ifstream finp("./src/example.txt");
    ofstream fout("./src/vasea-out.txt");
    if (!finp || !fout)
    {
        std::cout << "Error opening file" << std::endl;
        return 1;
    }
    copy(istream_iterator<char>(finp >> noskipws), istream_iterator<char>(), ostream_iterator<char>(cout));
    finp.clear();
    finp.seekg(0);
    finp.setf(ios_base::skipws);
    std::string word;
    string m,n;
    cout << endl;
    cout << "What word u want to chenge?? :" <<endl;
    getline(std::cin, m);
    cout << "Write new word? :" <<endl;
    getline(std::cin, n);
    bool found = false;
    while (!finp.eof() && !(finp >> word).fail())
    {
        if (word == m)
        {
            fout << n << " ";
            found = true;
        } else
            fout << word << " ";
    }
    if (!found)
        cout << "Can't find this word!!!!!!" << endl;
}
first of all its "change" not "chenge" lol

like this:
1
2
3
4
5
6
7
8
9
string line;
while(getline(finp,line))
{
     if(m == line)
     {
      // replace
     }

}

no, dont work((((
that allways say "cant find this word"

plz help do do this ((( i play with this code more 3 days and cant finish it ((((

need to do like this:
example.txt = Jorge is good boy
vase-out.txt =

Start code:
code show: Jorge is good boy
code show: What word u want to chenge??
we write: Jorge good
code show: Write new word?
we write: Mike bad
Finish code.

vasea-out = Mike is bad boy



how to do this?? plzz help :(
Topic archived. No new replies allowed.