Suppose I define some structure type ( studentInfo), then I declare an instance of it and I decide to also create a pointer to the instance like so:

typedef struct{

int age;
char idNum[9];
}
studentInfo;

...Code continues...

struct studentInfo mainInfo, *pMain;
pMain = &mainInfo;

Which of the following options is functionally equivalent to:

a. (p*Main).age = 20;
b. *pMain.age = 20;
c. pMain.age = 20;
d. *(pMain.age) = 20;

Respuesta :

Answer:

a. (p*Main).age = 20;

Explanation:

Pointers use ->

where as normal variable use . to access its members

pMain is the pointer.

*pMain is the value inside pMain.

pMain->age = 20;

This statement equals to

(*pMain).age = 20;

Answer is option a.