fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool replace(std::string& str, const std::string& from, const std::string& to) {
  5. size_t start_pos = str.find(from);
  6. if(start_pos == std::string::npos)
  7. return false;
  8. str.replace(start_pos, from.length(), to);
  9. return true;
  10. }
  11.  
  12. int main() {
  13. string texto = "gabriel = 1.73,derp = 1.80,";
  14. replace(texto, "1.73", "1.75");
  15. cout << texto;
  16. return 0;
  17. }
  18.  
  19. //https://pt.stackoverflow.com/q/50418/101
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
gabriel = 1.75,derp = 1.80,