fork download
  1. //Simple loop
  2. #include <iostream>
  3. #include <string>
  4. #include <ctype.h>
  5.  
  6. using namespace std;
  7.  
  8. string UserInput(string);
  9.  
  10. int main(void)
  11. {
  12.  
  13. string input;
  14.  
  15. // Enter user input
  16. cout << "Enter your input: ";
  17. cin >> input;
  18.  
  19. // Display user input
  20. cout << "You entered: " << UserInput(input) << endl;
  21. return 0;
  22.  
  23. }
  24.  
  25. // Example function to uppercase the string.
  26. string UserInput(string input) {
  27. for (int i = 0; i < input.length(); ++i) {
  28. input[i] = toupper(input[i]);
  29. }
  30. return input;
  31. }
Success #stdin #stdout 0s 3464KB
stdin
make this upercase
stdout
Enter your input: You entered: MAKE