Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

14 rader
369 B

  1. #pragma once
  2. std::string Replace(std::string str, const std::string& strToFind, const std::string& replaceWith) {
  3. size_t index = 0;
  4. std::string result = str;
  5. while (true) {
  6. index = result.find(strToFind, index);
  7. if (index == std::string::npos)
  8. break;
  9. result.replace(index, strToFind.size(), replaceWith);
  10. index += replaceWith.size();
  11. }
  12. return result;
  13. }