fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. int main()
  6. {
  7. const std::vector<std::pair<char, std::string> > html_chars = {
  8. { '&', "&amp;" },
  9. { '"', "&quot;" },
  10. { '<', "&lt;" },
  11. { '>', "&gt;" },
  12. };
  13.  
  14. std::string password = "\"&<>";
  15.  
  16. for (auto html_char : html_chars) {
  17.  
  18. size_t pos = password.find(html_char.first);
  19.  
  20. while (pos != std::string::npos) {
  21. password.replace(pos, 1, html_char.second);
  22. pos = password.find(html_char.first, pos + 1);
  23. }
  24. }
  25.  
  26. std::cout << password << std::endl;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
&quot;&amp;&lt;&gt;