fork(1) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. auto foo = "my_simple_humble_string"s;
  8.  
  9. auto count = 0;
  10.  
  11. for (auto read = 1; read < foo.size(); ++read) {
  12. if (foo[read] == '_') {
  13. ++count;
  14. ++read;
  15. foo[read - count] = toupper(static_cast<unsigned char>(foo[read]));
  16. } else {
  17. foo[read - count] = foo[read];
  18. }
  19. }
  20. foo[foo.size() - count] = foo[foo.size()];
  21. foo.resize(foo.size() - count);
  22.  
  23. cout << foo << endl;
  24. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
mySimpleHumbleString