-
If question ?
Code:
if(input == "mom" || "Mom" || "MOM" || "MOm" || "moM" || "MoM" || "mOM" || "mOm")
{
if(mom == 0 && dad == 0)
{
cout << "Im not yer mom ..........\n";
mom = 1;
}
if(dad == 0 && mom == 1)
{
cout << "I told you already im not yer Mother\n";
}
if(dad == 1 && mom == 0)
{
cout << "Im not yer Mom Either\n";
mom = 1;
}
if(dad == 1 && mom == 1)
{
cout <<"Im not yer parent at all u Hoe\n";
}
}
Why dont that work no matter wat i type it shows this and all the other if commands that have || in them how do i fix this
-
The pattern
Code:
if(a == x || y || z)
Doesn't do what you want. You need:
Code:
if(a == x || a == y || a == z)
-
Hey thanks alot brewbuck :P Cant totally learn from the books
-
Code:
int len = strlen(input);
for ( int ix = 0; ix < len; ix++)
{
input[ix] = tolower( (unsigned char) input[ix] );
}
if(input == "mom")
{
if(mom == 0 && dad == 0)
{
cout << "Im not yer mom ..........\n";
mom = 1;
}
if(dad == 0 && mom == 1)
{
cout << "I told you already im not yer Mother\n";
}
if(dad == 1 && mom == 0)
{
cout << "Im not yer Mom Either\n";
mom = 1;
}
if(dad == 1 && mom == 1)
{
cout <<"Im not yer parent at all u Hoe\n";
}
}
i think that would be much better...since you convert first to lower case...
-
Umm watever taht is it gives me a error saying wat is the include for that?
-
auralius' basic idea is to change all the letters of the string into lower case so you can compare more easily. You can ignore the actual implementation except for the use of tolower() which is found in <cctype>.