My task is to enter a string input into a char array. Here's what it's like :
as with the input is :
Ly Nguyen Khang
and the result only return
Please anybody help me understand what is wrong with this :(
part of my code :
#define INPUT_HELP_NAME "Please input name: "
#define INPUT_HELP_PHONE "Phone: "
cout << INPUT_HELP_NAME;
cout << INPUT_HELP_PHONE;
cin >> res->phone;
when it runs , it shows something like this :
Please input name : Phone :
cined it twice, causing it to not work. This is the correct way to do it:
char name; cin.getline(name,29); cout<<name;
cin.getline(name,29); is already
cined it, so there is no need for
cin>>name;ing it, that makes your results change because your code said to
cin it twice.