what i would do instead is either store m or f in the character array and then check
Code
if checkgender == m
printf(youre male)
else if (checkgender == f)
printf(youre female)
and then put it in a while loop so that you are garateed the correct answer.
Code
while checkgender != m || checkgender != f
printf(please enter your gender)
if checkgender == m
printf(youre male)
else if (checkgender == f)
printf(youre female)
end while
that would eliminate the function you have and 2 if statements.
if you insist that you want the full word in there you will have to use a function that converts the inputed text into FULL CAPS or FULL LOWERCASE to compare them incase they input maLe or FEMale
here is a quick function i wrote that works to change a character array into full uppercase (just pass its pointer to the function).
Code
//usage
//
//char array[7];
//cin >> array >>
//alpganum2upper(array)
void alphanum2upper(char *str)
{
int i = strlen(str); //length of the string
while (i-->0) //while the length is greater then zero deincrement
{
if (*str >= (int)'a' && *str <= (int)'z') //if the pointer to the current character of the array is greater then (int)a
{ //(:ps all that does is turn 'a' into a decimal number look it up on a ascii chart:) and str is less then (int)z
*str-=32; //if current char is between those lowercase values subtract 32 from it putting the character in the
} //ascii range for the equivalent upper case letter
str++; //increament the string pointer to point to the next letter in the string array
}
}
edit:: you could edit the function to accept a string length as an variable so you wouldnt have to include strings.h if you wanted.
This post was edited by AbDuCt on May 19 2012 12:11pm