Vijay Vijay - 1 year ago 40
C Question

Why do we have pointers other than void

I know that we have different pointers like

int
,
float
, and
char
. A
void
pointer is the only pointer which can hold all others.

Do the other pointers exist only for the flexibility to do pointer arithmetic?

Is there any other reason that pointers other than
void
are present in C language?

Answer Source

Type safety. Defining the type of pointers helps the compiler find errors where you are trying to use data of the wrong type through a pointer. That's the reason C has types in the first place.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download