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

Recommended Answers

All 6 Replies

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.

how to write program with void as data type

how to write program with void as data type

void *myvoid ;

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.