Hey guys i need some help here. I'm supposed to write a program that asks for a users id into a string. the string can only be 4 digits. Any idea how i can limit the string to only 4 characters?
And i also have to make a certain while loop but im getting some problems with it.
1 2 3 4 5 6 7 8 9 10 11 12 13
char gender;
string x;
cout << "What is your gender?" << endl;
cin >> gender;
while (( gender != 'M') && (gender != 'm') && (gender != 'f') && (gender != 'F'));
{
cout << "Please enter F or M." << endl;
cin >> gender;
}
cout << gender;
x = gender;
return x;