// пример с динамическим массивом
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>
using namespace std;
int main() {
cout << "String: ";
string line;
getline(cin, line);
auto length = line.length();
auto str = new char[length + 1];
copy(line.begin(), line.end(), str);
str[length] = 0;
cout << line << '\n' << str << '\n';
delete[] str;
system("pause > nul");
}
// пример со статическим массивом
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>
using namespace std;
int main() {
cout << "String: ";
string line;
getline(cin, line);
auto length = line.length();
char str[0xFF];
if (length < size(str)) {
copy(line.begin(), line.end(), &str[0]);
str[length] = 0;
cout << line << '\n' << str << '\n';
}
system("pause > nul");
}