i have question exact meaning of pointers phrase.
i have following method:
myfunc(const void * p) { ... }
and being called by:
mystruct *st; ... myfunc((char **)&st->arr);
i have experience pointers, in case still lost these pointers , casting.. can please accurate explanation how case works?
thanks
this seams bad quality code! maybe not dangerous, const
appears in prototype.
myfunc(const void * p)
accepts pointer , const
should mean won't touch it.
now, st
pointer mystruct
, st->arr
value of arr
member , &st->arr
memory address of arr
member. assuming arr
array, st->arr
value pointer.
so, (char**)
possibly correct type of &st->arr
, pointer character array. , if correct type, there no need cast!
you cast when need tell compiler handle data data. make sense, in case myfunc((const void *)&st->arr);
anyway, without further information on myfunc, belive true programmer intention myfunc((const void *) st->arr);
Comments
Post a Comment