includes word

I'm writing a code, and I'm want to have different out comes depending on wether a string includes a certain thing like if (re1 = happy || glad || fine) except if re1 includes happy or glad or fine.
closed account (zb0S216C)
Do you mean this:

1
2
3
4
if((re1 == happy) || (re1 == glad) || (re1 == fine))
{
   // ...
}

Note how the test was performed for each mood, and also note the operator used; The = (assignment) operator is not the same as == (equality). The assignment operator returns the left-hand operand, while the equality operator returns a Boolean.

Wazzak
Last edited on
Yah, but that makes it put out my else statement unless it actually is happy, glad, or fine. I want it to look for the words inside statements that the user would type into char re1[999], not just if re1 is one of the words.
I wonder if what you need is a switch statement?

This will allow different actions to be carried out depending on which mood is evaluated. Would be a good idea to use an enum to describe the moods.

Look elsewhere on this site showing examples of code.

Hope this helps.
Topic archived. No new replies allowed.