Thread: Help I'm Hopelessss

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Unhappy Help I'm Hopelessss

    I'm sorry I can't reply for some reason so if u feel u need to replace this go ahead.


    I'm messing around with the NOT !.
    At the first place I did like this !(1 || 0) and that suppose to be true I guess, but it doesn't recognize the '!'. Then I did a thread here and some guy told me it suppose to be (!true) but that didn't work either so what SHOULD I DO?!?!?!? pls help


    HELPPPPP pls

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    11
    oh and if it is (!true) so how do I make it like first evaluate (1 || 0) then evaluate NOT. (1 || 0) = true but NOT makes it false.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    !(1 || 0) and that suppose to be true I guess
    No, it's not.

    What do you mean by "not recognize"? You get a compile error?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    (1 || 0) evaluates to true. !(1 || 0) evaluates to false.

    if you do this:
    Code:
    if !(1 || 0)
    you will get a compile error. Do this:
    Code:
    if (!(1 || 0))

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Thankkkkss

    WOOWW thanks it's really (!(1/0)) and recognize = identify

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    11
    oh 1 last question: how do I make && evaluate after ||? means: if I do (1 || 1 && 0) that's not like 1 || 1 = 1 && 0 = 0

    it's 1 && 0 = 1 then 1 || 1 = 1
    I want AND to be evaluate before OR, how do I do that?

  7. #7
    The larch
    Join Date
    May 2006
    Posts
    3,573
    = is assignment, == is comparison for equality.
    To change the order in which subexpressions are evaluated, use () just like you do in math expressions.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by mat13mat View Post
    WOOWW thanks it's really (!(1/0)) and recognize = identify
    if something
    Is illegal.
    if (something)
    Is legal.

    Therefore, the error was that you did not write the if properly.

    Here's an example of your second q:
    if ( 1 || (1 && 0) )
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Here's an example of your second q:
    if ( 1 || (1 && 0) )
    which is equivalent to
    if ( 1 || 1 && 0 )
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I think I've an idea now how it was supposed to be. If && is to be first, then place it first:
    if ( (1 && 0) || 1 )
    Parenthesises make the expression less ambiguous, so I'd definitely recommend them, even if they are not required.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    mat13mat: You say you want to evaluate && after ||, but then you proceed to give examples of the opposite.

    If && is to be first, then place it first:
    That may help readability, but has zero effect on actual semantics. && always comes first because it has a higher precedence than ||. If you want to change this, you have to add extra parentheses around the OR expression.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #12
    Registered User
    Join Date
    Apr 2008
    Posts
    11
    I don't know if some1 will answer this here so I'll post a thread too, gm do w/e u want.
    If I make 2 files in 1 project, and I execute it, but I want to execute only 1 file how do I do it?
    I made a project with 2 files in it, 1 is int main() and 1 is int submain() now how do I execute the submain file? only int main() executes and I get to errors pls help.

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Functions needs to be called.
    Int main gets called upon program startup. Any other function you must call manually. There are not special.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    What C++ book are you using that doesn't cover this?

Popular pages Recent additions subscribe to a feed