C language-union, type definition

The stuff here is more complicated, but less.

Let’s share a sentence I read today (it’s about time management): We have twenty-four hours a day, eight hours of sleep, eight hours of work, and eight hours of freedom. The difference in life is created by the third 8 hours!

To the point!

One, typedef custom data type

1.

typedef int Length;

This makes Length an alias for the int type. So Length 10; Length 5; these two are equivalent to int 10; int 5;!

Format: typedef the original type and the new name of the original type;

2.

typedef struct Adate{
    int mounth;
    innt day;
    } Date;//这里Date可替代struct Adate.....到Date钱的所有东西。

2. Joint

union

Generally used to get the bytes inside an int/float/double

 

uinon example{
    int a;
    char b;
    }ep1,ep2;

Similar to struct, but the members in the union share the same memory space, and there is only one space, and the members use jointly.

Guess you like

Origin blog.csdn.net/qq_51182221/article/details/115310398