Thread: how to create a linked list for a structure within a structure?

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    how to create a linked list for a structure within a structure?

    Code:
     typedef struct {
      int tag;
      char* buffer;
    } IOEntry;
    
    struct {
      IOEntry ioEntry;
      IOEntry* next;
    };
    this is like a structure within another strucuture....

    just give me the implementation for adding a new node with tag and buffer and how point it to next node...since two structures are involved i m getting confused....

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That doesn't seem quite right.

    I'd expect it to be something like this:
    Code:
     typedef struct {
      int tag;
      char* buffer;
    } IOEntry;
    
    struct IONode {
      IOEntry ioEntry;
      struct IONode* next;
    };
    (Or something to that extent).

    What have you tried so far with regards to making a linked list?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. Duplicating value of pointer to linked list
    By zephyrcat in forum C Programming
    Replies: 14
    Last Post: 01-22-2008, 03:19 PM
  3. help! Placement of nodes in a Linked List
    By lostmyshadow in forum C Programming
    Replies: 6
    Last Post: 12-17-2007, 01:21 PM
  4. Problem with linked list ADT and incomplete structure
    By prawntoast in forum C Programming
    Replies: 1
    Last Post: 04-30-2005, 01:29 AM
  5. Linked List
    By jpipitone in forum C Programming
    Replies: 4
    Last Post: 03-30-2003, 09:27 PM