Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Trouble with &&'s
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Wed 04 Jun 2003 01:49 AM (UTC) |
Message
| Well, in addition to my other problem, I've got this one. Now these are just warnings and it still compiles, but to say the least they are annoying.
space.c: 10744: warning: suggest parentheses around && within ||
I know enough to tell what its saying, on line 10744 is the warning in space.c. So here is the section of code it seems to have trouble with:
if (arg1 != "ST-A1" || arg1 != "MID-C1" && !str_cmp("TAC",ch->pcdata->clan->name) )
{
send_to_char("You cannot order that!\n", ch );
send_to_char("Consult HELP TACMODELS\n\r, ch );
return;
}
Previous code checks to make sure they have a clan and such, and previous code does other checks, so its not a problem with something such as they don't have a clan or something.
Arg1 is defined as char and to me this seems like it should work, yet it still doesn't like it. Well, anyways, I was just wondering how I would rearange the if statement so that it wouldn't have the warning.
Thanks for any and all help. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Celestine
(29 posts) Bio
|
Date
| Reply #1 on Wed 04 Jun 2003 02:52 AM (UTC) |
Message
| It's just rather vague to the compiler. Let's call the three things you want to test A, B, and C. The way you have it, it's something like:
A or B and C
That could mean either
A or (combination of B and C)
or
(either A or B) and C
I believe that you can simply add parenthesis around the ones you want to group. So for the first case where it was either A or the combination of both B and C, you would do:
A || (B && C)
The other one should look something like:
(A || B) && C
I'm not 100% sure on this though. I usually try to rewrite it and just put one if inside of another. | Top |
|
Posted by
| Boborak
USA (228 posts) Bio
|
Date
| Reply #2 on Wed 04 Jun 2003 07:48 AM (UTC) |
Message
| It's just looking for this:
if ((arg1 != "ST-A1" || arg1 != "MID-C1") && !str_cmp("TAC",ch->pcdata->clan->name) )
The code would likely work without them in this case as the compilers default action would do what I believe you intended it to do. But, the compiler is simply asking you to clarify the logical statement you presented. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #3 on Thu 05 Jun 2003 04:10 AM (UTC) |
Message
| Thanks :) |
~Nick Cash
http://www.nick-cash.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
14,593 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top