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. { '"', "&quot;" },
  9. { '&', "&amp;" },
  10. { '<', "&lt;" },
  11. { '>', "&gt;" },
  12. }
  13. std::string password = "&&";
  14.  
  15. for (auto html_char : html_chars) {
  16.  
  17. size_t pos = password.find(html_char.first);
  18.  
  19. while (pos != std::string::npos) {
  20. password.replace(pos, 1, html_char.second);
  21. pos = password.find(html_char.first, pos + 1);
  22. }
  23. }
  24.  
  25. std::cout << password << std::endl;
  26.  
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:13:2: error: expected ',' or ';' before 'std'
  std::string password = "&&";
  ^
prog.cpp:17:17: error: 'password' was not declared in this scope
    size_t pos = password.find(html_char.first);
                 ^
prog.cpp:25:15: error: 'password' was not declared in this scope
  std::cout << password << std::endl;
               ^
stdout
Standard output is empty