# Thread: if (x && y || z)

1. ## if (x && y || z)

if I have something like

'm'==command[0] && 'u'==command[1] || 's'==command[2]

how does it work? Can I use both && and || together and if so what does it mean? Does it mean (this AND that) OR that or this (AND that OR that)

2. Sure you can use it. You just have to pay attention to presidence, or do the smart thing and use parenthesis to state exactly what you mean.

Quzah.

3. if (com[0] == 'm' || (com[1] == 'n' && com[2] == 'o'))

If com[0] equals 'm' or if com[1] equals 'n' and com[2] equals 'o,' then do what ever.

4. I think he might mean would it be equivilent to this:

( ('m'==command[0] && 'u'==command[1]) || ('m'==command[0] && 's'==command[2]) )

In which case, no.

5. just remember to use parenthesis when you're using both '&&' and '||'
Code:
```( XX && YY || ZZ )

// TRUE IF:
// XX AND YY
// OR:
// ZZ

( ( XX && YY ) || ZZ )

// TRUE IF:
// XX AND YY
// OR:
// ZZ

( XX && ( YY || ZZ))

// TRUE IF:
// XX
// AND:
// YY OR ZZ```
a great example of how parentesis make a big difference...

Code:
`if (!strcmpi("execute command", command))`
is there a way to check and see if command includes "execute command" without checking to see that command[0]=e and command [1]=x and so on...or perhaps to check that command[0-14]='execute command' ?

7. Use the strstr function. It should be in your reference.

8. I don't know what a reference is, aside from a dictionary or encyclopedia.

9. A nice reference is http://www.cppreference.com/

The specific page for strstr() is here, http://www.cppreference.com/com/stds...ls.html#strstr

10. I have no idea what this means
Code:
``` #include <string.h>
char *strstr( const char *str1, const char *str2 );

The function strstr() returns a pointer to the first occurrence of str2 in str1, or NULL if no match is found.```

11. You have to know what pointers are to understand that. The function simply finds the first occurrence of a substring within a larger string. Instead of returning an index to its find, it returns a pointer to it.