if-else statement error

Hey, I'm having a bit of trouble with if-else statements. I've got them working fine for the most part, but when I try to make the condition multiple letters (for example: "dad'), it gives an undefined error saying that "dad" has not been previously defined. I've already defined the variable previously as a string, and it works fine with numbers, So I'm at a loss. Can anyone help please?
Last edited on
can you display the code so that I can fix it and tell you the problem

Karl
Sounds like you're not quoting the string. Instead of this:
if (name == dad)

You'd want this:
if (name == "dad")
Aha! Wow, I feel like quite the idiot. Thanks a ton man.

That fixed that problem, but I have one more question:
Is there any way to make the condition for a conditional statement not case sensitive? Without making a ton of "else if's"?
Last edited on
you can make it not case sensitive but I think you will be needing a pretty long if-then-elseif-then-else. So instead of doing that you can use switch

1
2
3
4
5
6
7
8
9
int A;
switch(A)
{
     case 1: //do this
                  break;
     case 2://do this
                  break;
     default://do this
}

I don't think the switch statement will be that beneficial in this situation with out a little more work because he is dealing with strings and not letters, or numbers.
Topic archived. No new replies allowed.