fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. std::string camel_case( std::string str )
  5. {
  6. const int SIZE = str.size();
  7. if( str[0] >= 'a' && str[0] <= 'z' ) str[0] -= ' ';
  8. for( int i = 1; i < SIZE; ++i )
  9. {
  10. if( str[i] >= 'A' && str[i] <= 'Z' ) str[i] += ' ';
  11. }
  12. return( str );
  13. }
  14.  
  15. int main()
  16. {
  17. std::string animal;
  18. std::cout << "Please enter Cat or Dog: ";
  19. std::cin >> animal;
  20.  
  21. std::cout << camel_case( animal ) << std::endl;
  22.  
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 3432KB
stdin
CAT
stdout
Please enter Cat or Dog: Cat