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)
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)
AIM: MarderIII
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.
Hope is the first step on the road to disappointment.
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.
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.
just remember to use parenthesis when you're using both '&&' and '||'
a great example of how parentesis make a big difference...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
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
instead of saying
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' ?Code:if (!strcmpi("execute command", command))
AIM: MarderIII
Use the strstr function. It should be in your reference.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
I don't know what a reference is, aside from a dictionary or encyclopedia.
AIM: MarderIII
A nice reference is http://www.cppreference.com/
The specific page for strstr() is here, http://www.cppreference.com/com/stds...ls.html#strstr
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.
AIM: MarderIII
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.
Last edited by JasonD; 05-17-2003 at 06:57 AM.