Struct
Define a Struct
#ifndef CAR_H
#define CAR_H

struct Car
{
	char maker[80];
	int year;
};
#endif
		
Pass Struct to Function
#include <stdio.h>
#include <string.h>
#include "car.h"

void changeMaker(struct Car *c, char * m) // pass by reference
{
	strcpy(c->maker, m);
}

void disp(struct Car c) // pass by value
{
	printf("Maker: %s, Year: %d\n", c.maker, c.year);
}

int main()
{
	struct Car car;

	strcpy(car.maker, "Buick");
	car.year = 1998;

	changeMaker(&car, "Honda");
	disp(car);

	return 0;
}
		
Bit Field
#include <stdio.h>

struct status1
{
	unsigned int active;
	unsigned int sex;
};

struct status2
{
	unsigned int active:1;
	unsigned int sex:1;
};

int main()
{
	printf("Bytes: %lu\n", sizeof(struct status1)); // 4*2 bytes
	printf("Bytes: %lu\n", sizeof(struct status2)); // 2 bites, 4 bytes

	return 0;
}
		
Union
#include <stdio.h>
#include <string.h>

union Employee
{
	// age and hours share the same memory
	int age;
	int hours;
};

int main()
{
	union Employee e;

	e.age = 39;
	e.hours = 40;

	printf("%d: %d\n", e.hours, e.age); // 40 40

	return 0;
}