Basic C++ question about pointers/structures

LCD_Display

LCD_Display

@lcd-display-5nswBs Oct 11, 2024

In the book that I am using they use two notations for calling structure data members when using pointers.


(*pt).payRate * (*pt).hours ;
(pt ->payRate * pt ->hours);

I understand that in the first line * is dereferencing the pointer so that I can retrieve the data in the address stored in the pointer variable.

I know the second line gives me the same answer as the first but not sure how. Is the second line a short cut, or is it retrieving data differently than the first line?

Thanks in advance.

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform