fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. const std::vector<std::pair<char, std::string> > html_chars = {
  7. { '"', "&quot;" },
  8. { '&', "&amp;" },
  9. { '<', "&lt;" },
  10. { '>', "&gt;" },
  11. }
  12. std::string password = "&&";
  13.  
  14. for (auto html_char : html_chars) {
  15.  
  16. size_t pos = password.find(html_char.first);
  17.  
  18. while (pos != std::string::npos) {
  19. password.replace(pos, 1, html_char.second);
  20. pos = password.find(html_char.first, pos + 1);
  21. }
  22. }
  23.  
  24. std::cout << password << std::endl;
  25.  
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:6:13: error: 'vector' in namespace 'std' does not name a template type
  const std::vector<std::pair<char, std::string> > html_chars = {
             ^
prog.cpp:14:24: error: 'html_chars' was not declared in this scope
  for (auto html_char : html_chars) {
                        ^
stdout
Standard output is empty