If c is not your first language, you will really miss boolean primitive type. In other languages boolean is already defined, but in c there is no such type, it is actually using integer values instead.

It is really simple to implement a boolean value with typedef:

typedef enum { false, true } boolean;

Other option is to include stdbool.h.

Using typedef as an alias makes code more readable.

typedef data_struct Date;
typedef employee_struct Emp;

struct date_struct{
    unsigned short day;
    unsigned short month;
    unsigned short year;

struct employee_struct{
    char first_name[255];
    char last_name[255];
    Date hire_date;//note the use of typedef

//function definition
void setHireMonth(Emp *);
    Emp employee_1 = {0};
    //accessing the values goes in the same way
    employee_1.hire_date.day = 1;

void setHireMonth(Emp *ptrEmp){
    puts("Please give hire month for employee");
    scanf("%d", &ptrEmp->hire_date.month);

The example above shows that accessing the values is along the same rules as using struct.

Share This