I'm new to C++ and only been learning it for 3 days and so don't know all the syntax but I have a problem with this while statement. If anyone could help me it would be much appreciated!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
std::cout<<"Enter the name of the person you want to write to\n";
string name;
char friend_sex;
friend_sex=0;
cin>>name;
string friend_name;
cout<<"Enter friend's name\n";
cin>>friend_name;
while (friend_sex!='m'||friend_sex!='f'){
cout<<"Enter friend's sex (m or f)\n";
cin>>friend_sex;
}
cout<<"Dear "<<friend_name<<"\n";
cout<<" How are you?\n";
if (friend_sex=='m');
cout<<"If you see "<<friend_name<<" please ask him to call me\n";
if (friend_sex=='f');
cout<<"If you see "<<friend_name<<" please ask her to call me\n";
I want it so that it keeps looping the "Enter friend's sex" until an 'm' or an 'f' is entered...