fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5.  
  6. int main(){
  7. std::string word;
  8. char letter;
  9. int i;
  10. std::cout << "Enter a word: ";
  11. std::cin >> word;
  12.  
  13. std::ostringstream leetWord;
  14. for ( i = 0; i < word.size(); i++)
  15. {
  16. if ( word[i] == 'e')
  17. {
  18. leetWord << '3';
  19. }
  20. else if ( word[i] == 'i' )
  21. {
  22. leetWord << '1';
  23. }
  24. else if ( word[i] == 'x' )
  25. {
  26. leetWord << '*';
  27. }
  28. else
  29. {
  30. leetWord << word[i];
  31. }
  32. }
  33.  
  34. // Here you can refer to the ostringstream::str() function to
  35. // get a string
  36. std::string theWantedString = leetWord.str();
  37. std::cout << word << " => " << theWantedString << std::endl;
  38. }
  39.  
Success #stdin #stdout 0s 3432KB
stdin
cheese
stdout
Enter a word: cheese => ch33s3