Witam chce napisac narzedzie cos ala replace w edytorze tekstu, i mianowicie jesli mam w pliku test :
ala ma kotem
i chce zaminic
"ma" na "jest"
wychodzi cos nastepujacego "ala jestem" a gdzie kotem xd?
#include <iostream>
#include <fstream>
void display_members()
{
std::string oldWord;
std::string newWord;
std::string tmp;
std::string getcontent;
std::ifstream openfile ("test", std::ios::in | std::ios::app);
std::cin >> oldWord;
std::cin >> newWord;
// if(openfile.is_open())
// {
while(! openfile.eof())
{
getline(openfile,tmp);
while((tmp.find(oldWord)) != std::string::npos)
{
tmp.replace(tmp.find(oldWord),newWord.length(),newWord);
}
std::cout << ","<<tmp << " " << " ";
// openfile >> getcontent;
// std::cout << getcontent<< " ";
}
// }
openfile.close();
}
int main()
{
display_members();
}
juz siedze przy tym troche i sil do tego nie mam