/* program with struct examples */ #include /* declare a variable */ struct { int first; int second; } struct_var; /* declare a data type using struct */ struct struct_type { int first; int second; }; /* declare a data type using typedef and struct */ typedef struct { int first; int second; } typedef_struct_type; void print_struct_type_var(struct struct_type variable) { printf("The struct type variable has the values %d and %d\n", variable.first, variable.second); } void print_struct_type_var_pointer(struct struct_type *variable) { printf("The struct type variable has the values %d and %d\n", variable->first, variable->second); } void print_typedef_struct_type_var(typedef_struct_type variable) { printf("The typedef struct type variable has the values %d and %d\n", variable.first, variable.second); } void print_typedef_struct_type_var_pointer(typedef_struct_type *variable) { printf("The typedef struct type variable has the values %d and %d\n", variable->first, variable->second); } int main(void) { struct struct_type struct_type_var; typedef_struct_type typedef_struct_type_var; struct_var.first = 1; struct_var.second = 2; struct_type_var.first = 3; struct_type_var.second = 4; typedef_struct_type_var.first = 5; typedef_struct_type_var.second = 6; printf("The struct variable has the values %d and %d\n", struct_var.first, struct_var.second); print_struct_type_var(struct_type_var); print_struct_type_var_pointer(&struct_type_var); print_typedef_struct_type_var(typedef_struct_type_var); print_typedef_struct_type_var_pointer(&typedef_struct_type_var); return 0; }