From the course: Master C Language Pointers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with pointers in structures

Working with pointers in structures - C Tutorial

From the course: Master C Language Pointers

Start my 1-month free trial

Working with pointers in structures

- [Instructor] A pointer can be a structure member just like any valid variable type. In this code, two pointers dwell in the person structure: character pointer name and integer pointer age. These members are declared like any other structure variable but the asterisk operator identifies them as pointers. Storage for pointer member age is allocated at line 13. Standard structure member notation is used, my.age. And the return address is tested. The program exits if the null pointer is returned. Otherwise, at line 21 a value is assigned to the age member. The asterisk operator is used to reference the contents of the address. Dot notation is used for the age pointer structure member. At line 26, the base address of character array n is assigned to the address stored in pointer member name. The asterisk of operator isn't required as both values represent an address. And my.name doesn't need to be initialized or allocated because…

Contents