Tuesday, February 14, 2012

What is void pointer?


void pointers are pointers that can point to any data type. It can be used for any data type like int, char etc. In C language, type casting not required. But in C++, need to type cast it manually. Void pointer is also called Generic pointer.

void *vp; // it can be used for int, char or any data type
int *ip;
char *cp;
vp=(int*)ip; // vp as a integer pointer
vp=(char *)cp; // vp as a char pointer

No comments:

Popular Posts