C Programming

INITIALIZING STRUCTURES
This is similar to the initialization of arrays; the elements are simply listed inside a pair of braces, with each element separated by a comma. The structure declaration is preceded by the keyword static


	static struct date today = { 4,23,1998 };


ARRAYS OF STRUCTURES
Consider the following,


	struct  date  {
	     int month, day, year;
	};

Lets now create an array called birthdays of the same data type as the structure date


	struct date birthdays[5];

This creates an array of 5 elements which have the structure of date.


	birthdays[1].month = 12;
	birthdays[1].day   = 04;
	birthdays[1].year  = 1998;
	--birthdays[1].year;

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