Answers for "void pointer"

C++
2

void pointer

// A void pointer is a generic pointer, it has no associated type with it.
// A void pointer can hold address of any type and can be typcasted to any type.

void *ptr;	

///// Examples
void *v;
int *i;

int ivar;
char chvar;
float fvar;

v = &ivar; // valid 
v = &chvar; //valid
v = &fvar; // valid
i = &ivar; //valid 
i = &chvar; //invalid 
i = &fvar; //invalid
Posted by: Guest on February-08-2021

Browse Popular Code Answers by Language