Consider:
void takeInput()
{
string word;
cin >> word;
int n = word.length();
// Declaring character array
char *char_array = new char [n + 1];
// Copying the contents of the
// string to char array
strcpy(char_array, word.c_str());
for (int i = 0; i<n; i++)
cout << char_array[i];
}
error : Severity Code Description Project File Line Suppression State Error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. DSPROJECT c:\users\hp\source\repos\dsproject\dsproject\source.cpp 49