Which of the following accesses a local variable var in structure fred?

What is the correct way to access a local variable var in a structure named fred?

To access a local variable 'var' in a structure 'fred', use 'fred.var' if 'fred' is a structure variable, or 'fred->var' if 'fred' is a pointer to a structure. The correct answer depends on whether 'fred' is a structure or a pointer.

Explanation:

To access a local variable named var within a structure named fred, the correct syntax depends on whether fred is a structure variable or a pointer to a structure. If fred is a structure variable, you would use the dot operator (.), like so: fred.var. However, if fred is a pointer to a structure, you should use the arrow operator (->), which would be fred->var. Therefore, the correct answer for accessing a local variable var would depend on how fred is declared. If fred is a pointer to the structure, the correct access method would be A. fred->var;. If fred is a structure variable, the correct access method would be B. fred.var;. Options C and D are syntactically incorrect for accessing structure members.
← Excel tips amp tricks renaming worksheets Converting infix expression to postfix expression using stack →