can some one interpret the below line:
const void *const *ptr;
is it both the type & Ptr variable is constant?
can some one interpret the below line:
const void *const *ptr;
is it both the type & Ptr variable is constant?
After
const void *const *ptr;
You can change ptr
, but not *ptr
, or **ptr
ptr = <SOMETHING_ELSE>; /* ok */
*ptr = <SOMETHING_ELSE>; /* error */
**ptr = <SOMETHING_ELSE>; /* error, ignoring the point that you cannot even have an object of type void */
From the top of my mind:
void * const var; // The pointer is constant and var can change
const void * var; // The pointer can change but not var
so I would think that your syntax
const void * const *ptr;
means that ptr is a pointer to a pointer. So ptr would point to an address and that address cannot change (the first const). Also the address that ptr is located cannot change (the second const). But I am not totally sure of this.