Well, in this program I want it to take in a string or character array I really don't care which, for this instance I wouldn't know which is better. Afterwords, it compares those in if statements and sets a variable to a 1(female) or 2(male).

Anyways, here is what I have so far:

#include <iostream>
#include <string>

using namespace std;

void intro();
void questions();

char name[50];
int age;
int gender;
int orientation;

int main()
{
    questions();
    
    return 0;
}

void questions()
{
     
     string gendercheck;
     gender = 0;
     
     cout << "What is your first name?" << endl;
     cin >> name;
     
     cout << endl << endl << "Ah " << name << ", I think I am starting remember you now..." << endl
          << "How old are you again?..." << endl;
     cin >> age;
     
     cout << endl << endl << "Interesting... mmm." << endl;
     
     do
     {
         cout << "... Are you a male or a female?..." << endl;
         cin >> gendercheck;
         
         
         if(gendercheck != "male" || gendercheck != "female")
         {
                    cout << endl << "I'm sorry, but I do not recognise the statement \"" << gendercheck << "\"..." << endl;
         }
         else if(gendercheck == "male")
         {
                    gender = 2;
         }
         else if(gendercheck == "female")
         {
                    gender = 1;
         }
     }while(gender != 1 || gender != 2);
}

In the do while statement, no matter what I enter, its always saying the sorry message, even if i say male or female, so I assume im doing something stupid, thats causeing the entered male to be different than "male" in the comparison. I would really appreciate if this could be explained... :D Thanks in advance!

This should do it...your condition loops because it will only check the first if staement..i think

do
     {
         cout << "... Are you a male or a female?..." << endl;
         cin >> gendercheck;
         
         
        
         if(gendercheck == "male")
         {
                    gender = 2;
         }
         else if(gendercheck == "female")
         {
                    gender = 1;
         }
		 else
         {
                    cout << endl << "I'm sorry, but I do not recognise the statement \"" << gendercheck << "\"..." << endl;
         }
     }while(gender != 1 && gender !=2 );
}

Hand trace through the do/while loop with different conditions and you'll see that even if gender was equal to one, it would not be equal to 2 and vice versa, therefore your loop condition is true and the loop continues.

Thanks a ton! :D It worked beautifully. I thought it wasn't even comparing, but in fact it was just comparing it stricter than I thought. Anyzen your change worked, and jonsca, it was your sentence that made me see the logic in it. Also I set while(gender < 1 || gender > 2); Fixed it all, thank you guys.

This question has already been answered. Start a new discussion instead.