void pointer

Solutions on MaxInterview for void pointer by the best coders in the world

showing results for - "void pointer"
Maellys
29 Oct 2020
1// A void pointer is a generic pointer, it has no associated type with it.
2// A void pointer can hold address of any type and can be typcasted to any type.
3
4void *ptr;	
5
6///// Examples
7void *v;
8int *i;
9
10int ivar;
11char chvar;
12float fvar;
13
14v = &ivar; // valid 
15v = &chvar; //valid
16v = &fvar; // valid
17i = &ivar; //valid 
18i = &chvar; //invalid 
19i = &fvar; //invalid
20
21