toader
06-20-2009, 02:21 AM
writed this code.. but need to can change more 1 words.. how to do this? if i write 1 word that change.. but cant do 2 or more words((( help plz
#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;
}
plz help do do this ((( i work on 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 :(
#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;
}
plz help do do this ((( i work on 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 :(