Thread: how to interprete this signature..

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    You didn't create a new type in int *. You didn't create a new type in int []. Since you didn't create it, it's not a struct type. Only you can create structs.

  2. #17
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    thanks i think i understood this struct thing

    what this line means

    Code:
    if(!tree)return NULL;
    i know that ! means differ but here they didnt mention
    differ what??

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    Simple boolean magic.
    Basic rules:
    0 is false. Always.
    Everything else is true. Always.

    Basic if form:
    if (!tree == true)

    Let us assume that tree contains a value of NULL.
    Thusly, tree is interpreted as false in boolean form (since NULL is one way or another 0).
    Thus, we get:
    if (!false == true)

    The ! operator will invert the meaning of the value it is applied to, so we get:
    if (true == true)

    Or in other words, it's a short-hand for:
    if (tree == NULL)
    Last edited by Elysia; 10-27-2008 at 03:37 PM.
    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.

  4. #19
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    ok i understood this "!" thing
    igot problem understanding something else
    its a complex variable
    inside this node variable we have two sub variables
    data (which can be null or not)
    so is the sub variable next

    those two different sub variable

    we cant see them as one

    i dont know what the meaning of tree=null
    regarding its subvariables
    ??
    Last edited by transgalactic2; 10-27-2008 at 03:27 PM.

  5. #20
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by Elysia View Post
    Simple bool magic.
    if ( !tree ) is actually if ( !tree == true )
    So if tree == NULL, if (tree) would be false.
    Add the ! operator to change that false to true and you get:
    if (true == true)
    Or in other words, it's a short-hand for:
    if (tree == NULL)
    true and tree being in the same conditional statement is hard for my simpleton brain to wrap around.

  6. #21
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    See them as one what? They already are one node.

  7. #22
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    what are the values of root.data and root.next

    when we do
    Code:
    root=null;

  8. #23
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Code:
    if(!root)
    {
      /* Not messing with members of root goes here!!!!! */
    }

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    NULL pointers, as they are commonly referred to. Pointers pointing to "nothing."
    They cannot be dereferenced, but it is an easy way to tell if they point to something valid or not.
    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.

  10. #25
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    root is a pointer. It is not a struct.

  11. #26
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    when we are doing

    root=null
    we treat it as if it was a simple variable

    but its not
    Code:
    root=null;
    what are the values of root.data and root.next

    when we do

  12. #27
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,334
    Quote Originally Posted by transgalactic2 View Post
    when we are doing

    root=null
    we treat it as if it was a simple variable
    That's because it is. It is a pointer.

  13. #28
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by transgalactic2 View Post
    when we are doing

    root=null
    we treat it as if it was a simple variable

    but its not
    Code:
    root=null;
    what are the values of root.data and root.next

    when we do
    Again, and in english instead of C this time. If root is NULL (or root has NO value) then do NOT be trying to access its members. Unless the original question was how do I generate a seg fault with little effort, in which case be my guest, sport.

  14. #29
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    but its of a complex type

    so i guess
    it puts null on every sub variable of this type

  15. #30
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    Quote Originally Posted by master5001 View Post
    true and tree being in the same conditional statement is hard for my simpleton brain to wrap around.
    Updated example. Better now?
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What exactly is a function signature?
    By Sharke in forum C++ Programming
    Replies: 21
    Last Post: 07-01-2009, 11:21 PM
  2. Forum signature banners
    By Akkernight in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 04-04-2009, 03:31 AM
  3. Signature Image - 'Invalid File'
    By Tonto in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-16-2007, 10:32 PM
  4. Limitless signature?
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 12-30-2002, 10:32 PM