Thread: Pointer to a pointer struct

  1. #1
    Registered User
    Join Date
    Apr 2012

    Pointer to a pointer struct

    I'm working on a project that involves double pointers INSIDE a struct, and I'm kinda confused.

    typedef struct block {  
      unsigned int start_address;
     unsigned int end_address;  
    struct block **successors;  //array of successor block
                    } BLOCK;

    edit: First off, how do you link such structures together??
    Last edited by acpower; 05-07-2012 at 07:46 AM.

  2. #2
    Join Date
    Jul 2009
    Do everyone a favor and lose the typedef.

    Generally, variables of type pointer-to-pointer are asking you to assign an address of a pointer to them.
    struct block b;
    struct block *succ = malloc(sizeof(*succ));
    b.successor = ≻
    Disclaimer: This post shows my ignorance at the time of its making. I claim ownership of but not responsibility for all errors in it. Reference at your own peril.

  3. #3
    Registered User
    Join Date
    Apr 2012
    That's how the code was given to us. But anyway I think I got it, I'll see how it goes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 05-12-2011, 01:02 AM
  2. Replies: 3
    Last Post: 10-30-2009, 04:41 PM
  3. Replies: 6
    Last Post: 05-15-2009, 08:38 AM
  4. Replies: 4
    Last Post: 08-27-2007, 11:51 PM
  5. Pointer points to struct pointer
    By gogo in forum C Programming
    Replies: 4
    Last Post: 11-27-2001, 12:14 PM