[prev] [index] [next]

typedef and struct (cont)

With the above WorkerT type, we declare and use variables as ...

typedef struct {...} WorkerT;

WorkerT boss;         // single struct
WorkerT worker[1500];  // array of structs

boss.status = full_time;
boss.salary = 675000.00;
strcpy(boss.name, "John Elliot");
strcpy(boss.birthday, "29-02-1958");

for (i = 0; i < 1500; i++) {
	fgets(line,60,stdin);
	strcpy(worker[i].name, line);
	scanf("%f", &worker[i].salary);
	...
}