mardi 28 décembre 2021

Save two strings in one string and reverse in C++ [closed]

How can be possible in C++ merging two fixed length std::strings (x and y) in one (z) (possibly with the same length) and then recover them from this resulting z std::string? This would be kind of encoding-decoding procedure.

The following snippet clarifies my question:

std::string x = "Hello World!";              //x.size() = 11
std::string y = "How are you?";              //y.size() = 11

std::string z = merging_function(x, y);      //z.size() = 11

...
...other code
...

std::string decoded_x, decoded_y;
decoding_function(z, decoded_x, decoded_y); // From z will be possible recover x and y saving them in decoded_x and decoded_y

std::cout << decoded_x << std::endl;        // Hello World!
std::cout << decoded_y << std::endl;        // How are you?

Aucun commentaire:

Enregistrer un commentaire