please help me this is what i have idk how to continue well we enter string then we enter which part we want to edit , and write what will be writen on edited place . as the tittle says pls dont do other code try to fit it into what i have ty.
#include <iostream>
#include <string>
int main()
{
// enter string
std::string str ;
std::cout << "string? " ;
std::getline( std::cin, str ) ;
// enter which part we want to edit
std::string find_str ;
std::cout << "find? " ;
std::getline( std::cin, find_str ) ;
// what will be written on edited place
std::string replacement_str ;
std::cout << "replace with? " ;
std::getline( std::cin, replacement_str ) ;
// find the edit string
// http://www.cplusplus.com/reference/string/string/find/const std::string::size_type pos = str.find( find_str ) ;
if( pos != std::string::npos ) // if it was found
{
// http://www.cplusplus.com/reference/string/string/substr/
std::string modified_str = str.substr( 0, pos ) // the part before the find string
+ replacement_str // followed by the replacement string
+ str.substr( pos + find_str.size() ) ; // followed by the part after the find string
std::cout << "original string: " << str << '\n'
<< "modified string: " << modified_str << '\n' ;
}
// note: put the above in a loop to replace all occurrences
}