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) What is the equivalent syntax of this line of code using the * and . operators?
myMovie->pMovieTitle->pValue;
I tried
(*myMovie).pMovieTitle->pValue
which works, however
(*myMovie).(*pMovieTitle).pValue
Doesn't work.
2) Why are there two arrow operators when there are three pointers? myMovie, pMovieTitle and pValue are all pointers.
For example there are two arrow operators for this line of code:
myMovie->pMovieTitle->pValue;
and there are two arrow operators开发者_运维技巧 for this line of code:
myMovie->pMovieTitle->nBytes;
Even though pValue is a pointer and nBytes is not.
Your second attempt should be
(*(*myMovie).pMovieTitle).pvalue
; you can't dereference a struct member, only the value returned after accessing said member.The fact that
pValue
is a pointer is irrelevant;->
is used when the object on the left is a struct pointer, regardless of the type of the member named on the right.
(*((*myMovie).pMovieTitle)).pValue
It doesn't matter if pValue is a pointer you aren't dereferencing it anyway.
Because I think you have to do something like :
(*((*myMovie).pMovieTitle)).pValue
精彩评论