c - What is the equivalent syntax of this line of code(myMovie->pMovieTitle->pValue) using the * and . operators? -
struct values { char *pvalue; //character string int nbytes; //amount of bytes }; struct movie { values *pmovietitle; //name of movie }; movie *mymovie;
1) equivalent syntax of line of code using * , . operators?
mymovie->pmovietitle->pvalue;
i tried
(*mymovie).pmovietitle->pvalue
which works, however
(*mymovie).(*pmovietitle).pvalue
doesn't work.
2) why there 2 arrow operators when there 3 pointers? mymovie, pmovietitle , pvalue pointers.
for example there 2 arrow operators line of code:
mymovie->pmovietitle->pvalue;
and there 2 arrow operators line of code:
mymovie->pmovietitle->nbytes;
even though pvalue pointer , nbytes not.
your second attempt should
(*(*mymovie).pmovietitle).pvalue
; can't dereference struct member, value returned after accessing said member.the fact
pvalue
pointer irrelevant;->
used when object on left struct pointer, regardless of type of member named on right.
Comments
Post a Comment