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.

  1. your second attempt should (*(*mymovie).pmovietitle).pvalue; can't dereference struct member, value returned after accessing said member.

  2. the fact pvalue pointer irrelevant; -> used when object on left struct pointer, regardless of type of member named on right.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -