std::fstream pasaka("my_file", std::fstream::in | std::fstream::out);
std::fstream pusuku("my_file1", std::fstream::in | std::fstream::out);
std::string line;
if (pasaka.is_open())
{
//while (std::getline(pasaka, line))
//std::cout << line << std::endl;
// pusuku << line << std::endl;
while (!pasaka.eof())
{
if (pasaka.get() == 'a')
{
pasaka.seekp((pasaka.tellp() - static_cast<std::streampos>(1)));
pasaka.put('u');
pasaka.seekp(pasaka.tellp());
}
else if (pasaka.get() == 'A')
{
pasaka.seekp((pasaka.tellp() - static_cast<std::streampos>(1)));
pasaka.put('U');
pasaka.seekp(pasaka.tellp());
}
}
pusuku.close();
pasaka.close();
}
else {
std::cout << "Faild to open" << '\n';
}
return 0;
the issues:
- if the code that is commented (first while loop and everything in it ) the program does 0 switches
2)if A is found it doesn't delete the A characther but just adds U
result received: ( from txt file ) uuuuuuu UAUAAAA
result expected ( from txt file ) uuuuuuu UUUUUUU