Jump to content

Need help with printinh a linked list in c


Recommended Posts

Hi All,

I have some troubles with implementing a function that printing the linked list.

This is the struct:

typedef struct item

{

int data;

struct item* next;

} sItem;

I need to implement this:

void print_list(sItem* head)

How do I do that?

Many Thanks!

Link to comment
Share on other sites


Assuming the last 'next' member is zero:

void print_list(sItem* head)

{

   for( ; head; head=head->next )

   {

      printf( "%d\n", head->data );

   }

}

Edited by Mijzelf
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...