0

what is meant by generic linked list. how to insert and delete the elements in the linked list which is generic

5
Contributors
6
Replies
8
Views
9 Years
Discussion Span
Last Post by Narue
0

A generic linked list, in C, is a linked list with a void* in the node for the data.


ON another note this is depreciated.

0

>ON another note this is depreciated.
Do you mean deprecated? If so, you're wrong. If not, please elaborate.

0

how to write program with void as data type

void pointer can point any type of data.

Example:

void* voidPtr; //void pointer
int iVal=10;
char cVal='a';
voidPtr=&iVal; //void pointer pointing to int type
printf("num=%d",*(int*)voidPtr); //casting (void* to int*)

voidPtr=&cVal; //void pointer pointing to char type
printf("\nchar=%c",*(char*)voidPtr); //casting(void* to char*)

you can cast void* to any other pointer type.

0

>you can cast void* to any other pointer type.
Any other object pointer type. void* isn't compatible with function pointers, for example.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.