Thread: Problem with user defined type value?

  1. #1
    Registered User
    Join Date
    Nov 2014
    Posts
    45

    Problem with user defined type value?

    Say i have a structure like this:

    Code:
    typedef struct node {  int number;
                                   struct node *next;
                                 }NODE;
    
    int main ()
    {
      NODE *head=0;
    
    return 0;
     
    }
    As you can see, its linear data structure, and this is the beginning of it. I don't understand what it means that head equals zero, does it means it points at nothing or it means value it has is zero (number) ?

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    Replace `NODE *' with `int *', could you answer the revised question?

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  3. #3
    Registered User
    Join Date
    May 2013
    Posts
    228
    Quote Originally Posted by cdummie View Post
    does it means it points at nothing or it means value it has is zero (number) ?
    It depends on your definition of "nothing". Assigning 0 to a pointer means that it 'points to address 0'.
    In most systems dereferencing a null pointer will cause a segmentation fault, so in that sense, you could say it points to 'nothing'...

  4. #4
    Registered User
    Join Date
    Nov 2014
    Posts
    45
    Quote Originally Posted by phantomotap View Post
    O_o

    Replace `NODE *' with `int *', could you answer the revised question?

    Soma
    I think i see it now, it means it points at nothing, the fact that the pointer is NODE only means it points to a variable whose type is NODE.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-29-2011, 01:09 AM
  2. how to convert char string to user defined data type
    By prdeepss in forum C Programming
    Replies: 5
    Last Post: 08-02-2009, 09:59 AM
  3. user defined operator returns another type?
    By TriKri in forum C++ Programming
    Replies: 8
    Last Post: 09-20-2007, 02:47 AM
  4. Determining a user-defined class type
    By Mingzhi in forum C++ Programming
    Replies: 4
    Last Post: 07-20-2004, 05:33 PM
  5. Static Capabilities for a User-Defined Type
    By gozlan in forum C# Programming
    Replies: 1
    Last Post: 04-08-2003, 11:21 AM