void *
is a generic pointer, but what about void **
? Is void **
also a generic pointer?
Can we typecast void **
to int **
, char **
and so on.
I would be thankful to stack overflow family for any information on this.
The void pointer in C is a pointer that is not associated with any data types. It points to some data location in the storage. This means that it points to the address of variables. It is also called the general purpose pointer. In C, malloc() and calloc() functions return void * or generic pointers.
Generic Pointers / Void pointerSince you cannot have a variable of type void, the pointer will not point to any data and therefore cannot be dereferenced. It is still a pointer though, to use it you just have to cast it to another kind of pointer first. Hence the term Generic pointer.
No difference. void pointer is itself called generic pointer. Show activity on this post. If you declare a pointer to void it's called Generic Pointer since you have to cast it to another kind of pointer first.
void (C++) If a pointer's type is void* , the pointer can point to any variable that's not declared with the const or volatile keyword. A void* pointer can't be dereferenced unless it's cast to another type. A void* pointer can be converted into any other type of data pointer.
No. void**
is a pointer to void*
, and nothing else. Only void*
acts like a generic pointer.
Note that actually trying it will probably yield consistent results, but only the above is mandated by the Standard, anything else is Undefined Behaviour and may crash without mercy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With