If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable? ans. & . -> *
Question
If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?
ans. &
.
->
Solution
The "->" operator is used to access data members of a structure through the pointer variable. Here's how it works:
-
First, you declare a structure. For example, you might have a structure called "student" with data members "name" and "age".
-
Then, you declare a pointer variable that points to a structure of type "student". For example, you might declare a pointer variable "p" like this: struct student *p;
-
Now, you can use the "->" operator to access the data members of the structure through the pointer variable. For example, if you want to access the "name" data member of the structure that "p" points to, you would write: p->name;
So, in conclusion, the "->" operator is used to access data members of a structure through a pointer variable.
Similar Questions
Which operator is used to access data members of the outer structure?
How do you access a member of a structure using a structure pointer in C?*1 pointWith the dot operator (.)With the arrow operator (->)With the ampersand (&)With the asterisk (*
The operator used to get value at address stored in a pointer variable isa.*b.&c.&&d.||
Which operator is used to obtain the memory address of a variable in C?
Which of the following statements about pointers is true?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.