fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <locale>
  4. #include <cctype>
  5.  
  6. std::string convertString(std::string s)
  7. {
  8. for(std::string::iterator it = s.begin(); it != s.end(); ++it)
  9. {
  10. if (isupper(*it)) *it = tolower(*it);
  11. else if(islower(*it)) *it = toupper(*it);
  12. else if(isdigit(*it))
  13. {
  14. //write code here...
  15. }
  16. }
  17. return s;
  18. }
  19.  
  20. int main()
  21. {
  22. std::cout << "Input string to convert: " << std::flush;
  23. std::string toconvert;
  24. std::getline(std::cin, toconvert);
  25. std::cout << "Converted string: " << convertString(toconvert) << std::endl;
  26. }
Success #stdin #stdout 0s 3476KB
stdin
Hello, ThIs Is SpArTa 0123456789
stdout
Input string to convert: Converted string: hELLO, tHiS iS sPaRtA 0123456789