fork download
#include <iostream>
#include <sstream>
#include <vector>

std::string toCamelCase(const std::string& text) {
    std::stringstream ss(text);
    std::vector<std::string> words;
    std::string word;

    while (ss >> word) {
        words.push_back(word);
    }

    std::string camelCaseText = words[0];
    for (size_t i = 1; i < words.size(); ++i) {
        word = words[i];
        if (!word.empty()) {
            word[0] = std::toupper(word[0]);
            camelCaseText += word;
        }
    }

    return camelCaseText;
}

int main() {
    std::string inputText = "BOB loves-coding";
    std::string outputText = toCamelCase(inputText);
    std::cout << outputText << std::endl;
    return 0;
}
Success #stdin #stdout 0.01s 5288KB
stdin
BOB loves-coding
stdout
BOBLoves-coding