2006-01-20 : 22:40 -Edit- -Reply- -Top- linked List?
Updated by asif on 2006-01-20 22:41
--------------------------------------------------------------------------------
Hi dear,
I have a list of linked list of element like below.the last item of the list points back to one of the item of the list.
O---> |A|---> |B|--->|C|--->|D|
Here, O represnt of Head
so, My question is the function what returns the number of items in linked-list of the above type.
another question is same but here list is much longer than above.
I tried like
Int getNumberOfItems( void *listHead ) {
int data;
node next;
head =malloc(sizeof(void *listhead));
second =malloc(sizeof(void *listhead));
thrird =malloc(sizeof(void *listhead));
fourht=malloc(sizeof(void *listhead));
head->data=A
head->next=second
head->data=B
head->next=third
head->data=C
head->next=fourth
head->data=D
head->next="Here i dont know where it will reference"
and what will return this function?
Please give me answers of both questions diffrently.
Waiting for positive reply.