Which choice is a reason to specify the type of a pointer instead of using void *, which works as a pointer ro any type?

Advertisement

  • The compiler needs the dara type to make sure that the pointer is not going to be used on illegal non-pointable types such as functions, labels, pointers, and reference.
  • void * does not work for any type. The language does not allow assigning anything other than void to a pointer to void *.
  • The compiler needs the data type to know how much memory to allocate for the pointer, because different data types require different pointer lengths.
  • Yes, it causes a compiler error because one field is defined as having a size of 0.
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.