13.07.2015 Views

C struct, typedef, enum & union - Tenouk C & C++

C struct, typedef, enum & union - Tenouk C & C++

C struct, typedef, enum & union - Tenouk C & C++

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

STRUCT, TYPEDEF, ENUM & UNION• Since pPartPtr points to an object of type <strong>struct</strong>inventory, we dereference the pointer to access the membersof the object using the following statements,(*pPartPtr).nPartNo(*pPartPtr).fBuyCost(*pPartPtr).fSellingPrice• Similar changes have been made to printpart() function.• Note, the parentheses are necessary here because the .operator has higher precedence than the indirection operator, *.• We must first dereference the pointer, and then select itsappropriate member.• Since, for efficiency, pointers to <strong>struct</strong>ures are often passed tofunctions, and, within those functions, the members of the<strong>struct</strong>ures are accessed, the operation of dereferencing a<strong>struct</strong>ure pointer and a selecting a member is very common inprograms.www.tenouk.com, © 38/93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!