I was making a simple program in c++ to convert a string to a char array and then print it out. My code is:
string UserImput;
int lenght;
void Test()
{
getline(cin, UserImput);
lenght = UserImput.size();
char char_array[lenght + 1];
copy(UserImput.begin(), UserImput.end(), char_array);
cout << char_array;
}
The error I am getting is "expression must have a costant value" and I do not know why.