fork download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. void toUpper(string &s)
  7. {
  8. for(auto &p:s) // Loop through each char in the string
  9. if (islower(p))
  10. p =toupper(p);
  11. }
  12.  
  13. int main()
  14. {
  15. string name;
  16. cout << "Enter a name :";
  17. cin >> name;
  18. toUpper(name);
  19. cout << "The string in Upper Case is: " << name << endl;
  20. }
  21.  
  22.  
  23.  
Success #stdin #stdout 0s 4380KB
stdin
ChRiStOpHe-+037
stdout
Enter a name :The string in Upper Case is: CHRISTOPHE-+037