#include <string>
#include <iostream>
#include <memory>
int main()
{
std::string s1;
std::string s2;
while(std::cin >> s1 >> s2)
{
std::string s3 = s1 + s2;
int size = s3.length();
std::cout << size <<'\n';
std::unique_ptr<char[]>ptr(new char[size]);
for(int i=0; i<size; ++i)
{
ptr[i] = (s3.c_str())[i];
}
for(int i=0;i<size;++i)
{
std::cout << ptr[i];
}
break;
}
}
This is an exercise to concatenate two strings and store them in array of char. INitially, I wss having trouble passing int he string into the array. Later, I managed to convert it into c string and pass it into array.
I was wondering is there a better medhtod to deal with it