C Programming

Practise Exercise 11: Pointers & Structures

JavaScript compatible inter-active version of this test.

1. Declare a pointer to a structure of type date called dates.

2. If the above structure of type date comprises three integer fields, day, month, year, assign the value 10 to the field day using the dates pointer.

3. A structure of type machine contains two fields, an integer called name, and a char pointer called memory. Show what the definition of the structure looks like.

4. A pointer called mpu641 of type machine is declared. What is the command to assign the value NULL to the field memory.

5. Assign the address of the character array CPUtype to the field memory using the pointer mpu641.

6. Assign the value 10 to the field name using the pointer mpu641.

7. A structure pointer times of type time (which has three fields, all pointers to integers, day, month and year respectively) is declared. Using the pointer times, update the field day to 10.

8. An array of pointers (10 elements) of type time (as detailed above in ' 7.), called sample is declared. Update the field month of the third array element to 12.


ęCopyright B Brown. 1984-1999. All rights reserved.