Strings

  • + 0 comments
    #include <iostream>
    #include <sstream>
    
    std::string getInput() {
        std::string inputt{};
        std::cin >> inputt;
        return inputt;
    }
    
    int main() {
       std::string first_val{getInput()};
       std::string second_val{getInput()};
       std::string first_char_of_first_value {first_val[0]};
       std::string second_char_of_first_value {second_val[0]};
       std::cout << first_val.length() << " " << second_val.length() << '\n';
       std::cout << first_val+second_val << '\n';
       std::cout << first_val.replace(0,1,second_char_of_first_value) << " " << second_val.replace(0,1,first_char_of_first_value) << '\n';
    
        return 0;
    }