Use the getline function to read the user's input and assign that input to the character array
#include <iostream>
using namespace std;
int main ()
{
char name[80] = {'J', 'e', 'f', 'f', '/0' };
cout << "Enter your name: ";
cin.getline(name, 80);
cout << "Your name is " << name;
return 0;
}
Related examples in the same category