I have a problem, When i run my Program, it tells me to input a name which is what is't meant to do, but when it says are you sure it's (name), it only shows the first letter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
usingnamespace std;
int main ()
{
char yeh, yes, ya, yep;
char yess;
char Name;
char Answer;
yess == yeh, yes, ya, yep;
cout << "What is your name?\n";
cin >> Name;
cout << "Are you sure it is " << Name << "?";
cin >> Answer;
if (cin >> yess)
cout << "\nGood!";
else
cout << "\nSo,";
system("PAUSE");
return 0;
}
I think you should use std::string rather than char.
eg
1 2 3 4
string name;
cout << "What is your name?";
cin >> name;
cout << "Are you sure it is " << name << "?" << std::endl;
You are using type char as the variable which for your program will store 1 character only. If you want to get input of a name - a string of characters combined - you need to use a string type as the storage variable.
hth
he will have an issue if he types in a first and last name so: getline(cin,"name of your string")
will get whatever you type in for that line of strings
otherwise if he types in Mr. Anderson it will only output Mr.