Thread: Is this if/strcmp correct?

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by SlyMaelstrom
    *yawn*

    I'm going to cherish the moment.

    If you reread the posts, you'll see that I asked what the OP meant by "continue past". He then replied with this:

    Code:
    if x isn't "x" or "y" or "z" then
    ....
    else
    .....
    Implying HE WANTS TO ENTER THE STATEMENT if the variable isn't one of the three literals. I also understood "continue past" to skip over the if, then he said he meant to enter into the if. There for, the condition should be correct.
    Cherish whatever you like. You're wrong. I dare you to enter input with the code I have provided that doesn't enter the if. It can't be done. There is NO WAY to NOT enter that if with the code you're saying is "correct". Go on, do it. Put anything for an argument to that if check, and have it not enter the if.

    Cherish away.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by 3saul
    Sorry for causing all of this...as you can see I am a beginner and yes this is what I'm wanting

    Code:
    if x isn't "x" or "y" or "z" then
    printf("%s isn't the same as x or y or z",x)
    else
    printf("%s is the same as x or y or z",x)
    Read your sentence. You don't say "if this isn't that or the this isn't the other thing..." you have to say "if this isn't that and it isn't the other thing...". It has to be and because if you use or it will always evaluate to one of them being true. If it is y then by definition it "is not x". Therefore, "is not x" is true, because it is y. And if it "is x", then it must be "not y". So that's true. Using OR, you will always have one of them "not be" something else.

    But hey, no one around here listens to anything I say because I must be stupid or something.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Ah........ .........

    You had me looking left and you went right. I thought you weren't able to enter the statement. Quzah is correct. I can still cherish, though. Muahaha... Muah.... muahahahahahhahahaha.
    Sent from my iPadŽ

  4. #19
    Registered User
    Join Date
    Jan 2006
    Posts
    62
    Quzah..you are correct. It's early morning here so that accounts for the slowness...

    Code:
    x must not equal "x" AND must not equal "y" AND must not equal "z"
    Thank you very much

  5. #20
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    The funny thing is I just answered this very same question in the C++ forum correctly a few days ago. Funny how trying to pay attention to class can make it difficult to properly analyze a question.
    Sent from my iPadŽ

  6. #21
    Registered User
    Join Date
    Feb 2006
    Location
    Chennai, India
    Posts
    3
    The strcmp() function return an integer less than zero or equal
    to zero(If both strings are same) or greater than zero.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux for GNU/Linux is not correct?
    By password636 in forum Linux Programming
    Replies: 8
    Last Post: 03-31-2009, 08:30 PM
  2. Is this correct : passing strings?
    By socket in forum C Programming
    Replies: 15
    Last Post: 11-25-2008, 02:03 PM
  3. correct malloc use
    By s_siouris in forum C Programming
    Replies: 10
    Last Post: 05-28-2008, 10:49 PM
  4. Replies: 1
    Last Post: 05-26-2004, 12:58 AM
  5. Why I couldn't see the correct format of a file?
    By miketv in forum C Programming
    Replies: 2
    Last Post: 01-23-2002, 10:59 PM