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?
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?
Solution
The operator used to access data members of a structure through a pointer variable is the "->" operator.
Here's a step-by-step explanation:
-
Suppose you have a structure named 'struct_name' and it has a member 'member_name'.
-
You declare a pointer to this structure like this: struct_name *pointer_name;
-
Now, if you want to access 'member_name' through 'pointer_name', you would do it like this: pointer_name->member_name;
So, the "->" operator is used to access data members of a structure through a pointer variable.
Similar Questions
The operator used to get value at address stored in a pointer variable isa.*b.&c.&&d.||
Identify the incorrect syntax for a pointer to a structure:Assuming the structure: struct temp { int b; } *obj;
What is the base data type of a pointer variable by which the memory would be allocated to it?a.intb.floatc.No datatyped.unsigned int
Which of the following cannot be a structure member?*1 pointA. FunctionB. ArrayC. StructureD. None of the above
What is the correct syntax for using the indirection operator to print the value pointed to by a pointer ptr?
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.