d01 ex04 erreur saute des find possibles

This commit is contained in:
Hugo LAMY
2022-02-07 19:27:30 +01:00
parent dc144127a9
commit ea0f9b085a
12 changed files with 40 additions and 9 deletions

View File

@@ -22,12 +22,17 @@ void Sed::replace() {
{
if (str[0] == this->_find[0])
{
tmp = str[0];
file.get(str, len, EOF);
if (this->_find.compare(1, len - 1, str) == 0)
if (len == 1)
new_file << this->_replacement;
else
new_file << tmp << str;
{
tmp = str[0];
file.get(str, len, EOF);
if (this->_find.compare(1, len - 1, str) == 0)
new_file << this->_replacement;
else
new_file << tmp << str;
}
}
else
new_file << str;