Click to See Complete Forum and Search --> : Can you show me how to use the LINK LIST in easy way????


Loc Nguyen
09-28-2001, 02:39 AM
Hi all, I didn't understand about the LINK LIST in C or C++ much. You
would like you show me the definition of the LINK LIST and how to use it
in easy way... Please give me the example and explanation

Many Thanks,
Loc Nguyen

jonnin
09-28-2001, 01:46 PM
there is no such thing, really. LL's are a user defined type.

here is old way:
struct ll
{
int data;
ll* next;
};

...
insert first guy:

ll* head;
head = new ll;
head->data = number;
head->next = NULL;

insert in front, easiest way:

ll* tmp
tmp = new ll;
tmp->data = number;
tmp->next = head;

etc.

processing, just do this
tmp = head;
while (tmp-> next != NULL)
{
...

tmp = tmp-> next;
}

etc...

"Loc Nguyen" <locnguyen1@hotmail.com> wrote:
>
> Hi all, I didn't understand about the LINK LIST in C or C++ much. You
>would like you show me the definition of the LINK LIST and how to use it
>in easy way... Please give me the example and explanation
>
>Many Thanks,
>Loc Nguyen