fork download
  1. #include <cctype>
  2. #include <cstdlib>
  3. #include <cstring>
  4. #include <iostream>
  5.  
  6. char *
  7. my_strupr(char *s)
  8. {
  9. char *start = s;
  10. for (; *s; ++s)
  11. *s = std::toupper(*s);
  12. return start;
  13. }
  14.  
  15. char *
  16. my_strdup(char const *src)
  17. {
  18. char *dst = new char[ std::strlen(src) + 1 ];
  19. std::strcpy(dst, src);
  20. return dst;
  21. }
  22.  
  23. char *
  24. strupr_copy(char const *s)
  25. {
  26. return my_strupr(my_strdup(s));
  27. }
  28.  
  29. int
  30. main()
  31. {
  32. char const *src = "Hello, World!";
  33. char * dst = strupr_copy(src);
  34. std::cout << src << " --> " << dst << '\n';
  35. delete dst;
  36. }
  37.  
Success #stdin #stdout 0s 4456KB
stdin
Standard input is empty
stdout
Hello, World! --> HELLO, WORLD!