1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development A circular list in C

Discussion in 'Software' started by ocha, 16 Dec 2008.

  1. ocha

    ocha Minimodder

    Joined:
    29 Dec 2001
    Posts:
    452
    Likes Received:
    0
    Hi All,

    does anyone know what is meant by creating a circular list in C? I understand this would create a loop but that is the intention at the moment. It is for some work at Uni but I am in a bit of a bind and need a pointer at least.

    Thanks
     
  2. notatoad

    notatoad pretty fing wonderful

    Joined:
    25 Jun 2004
    Posts:
    3,213
    Likes Received:
    60
    a circular list is a linked list where the last element has a pointer to the first element.

    Code:
    struct listitem {
      some data
      pointer to next element
    }
    
    list l = pointer to element a
    
    listitem a = some data, pointer to b
    listitem b = some data, pointer to c
    listitem c = some data, pointer to a
    
    (my knowledge of C is pretty crappy, but i think this gets the point across)
     
    Last edited: 16 Dec 2008
  3. Nedsbeds

    Nedsbeds Badger, Slime, Weasel!!

    Joined:
    16 May 2002
    Posts:
    1,972
    Likes Received:
    9
    Yes, yes you do.... (tee hee sorry!)

    Is it the actual code you are struggling on or the concept of a circular list?
     
  4. ocha

    ocha Minimodder

    Joined:
    29 Dec 2001
    Posts:
    452
    Likes Received:
    0
    I wondered if anyone would get that.

    I understand the concept, I was having some problems putting it into practice. I think I have now figured it out. Not well however, though hand in for it was Friday, so I don' have to worry about it much.

    Thanks for your help guys.
     
Tags:

Share This Page