“Understanding custom types: structures, enumerations, unions”

Foreword This article will introduce three custom types in C language: structure, enumeration and union. These data types are very important in C language, they allow programmers to create their own data types to meet specific needs. By understanding these data types, you can better grasp the characteristics and applications of C language. 1. Structure […]

Custom types – structures, enumerations, unions

Table of Contents 1. Structure 1.1 Declaration of structure type 1.2 Self-reference of structure 1.3 Definition and initialization of structure variables 1.4 Structure memory alignment Modify the default alignment number 1.5 Structure parameter passing 2. Structure implements bit segments (filling of bit segments & portability) 2.1 What is a bit segment (segmented by binary bits) […]

C language custom types: unions and enumerations

?Record 1. Union type declaration 2. Characteristics of the consortium 3. Calculation of union 4. Declaration of enumeration type 5. Advantages of enumeration types 6. What are the uses of enumeration types? 1. consortium 1.1 Union type declaration Like a structure, a union is also composed of two or more members, and these members can […]

Explanation of structures, enumerations, and unions in C language

Table of Contents 1. Structure 1.1 Structure writing format 1.2 Definition of structure variables 1.3 Structure initialization and access to members 1.4 Structure parameter passing 1.5 Structure memory size calculation 1.6 Structural body position break 1.6.1 How bit breaks allocate space 2. Enumeration 2.1 Value acquisition and assignment of enumerations 2.2 Advantages of enumeration 3. […]

20. Custom types: enumerations and unions

1 Enumeration type 1.1 Declaration of enumeration types example: enum Day//week {<!– –> Mon, Tues, Wed, Thur, Fri, Sat, Sun }; enum Sex//gender {<!– –> MALE, FEMALE, SECRET }; enum Color//Color? {<!– –> RED, GREEN, BLUE }; The enum Day, enum Sex, and enum Color defined above are all enumeration types. The contents in {} […]

Memory alignment of structures, unions and their simple applications

Table of Contents 1. Memory alignment of structures 1. Memory alignment rules 2. Give examples 3. Why does memory alignment exist? 2. Consortium 1. A brief introduction to the consortium 2. Give examples 3. Calculation of consortium size 4. Simple application of consortium 1. Memory alignment of structures 1. Memory alignment rules 1. The first […]

In-depth explanation of custom types (structures, enumerations, unions)

Foreword I believe we are all familiar with structures, but structures belong to a custom type, so what is special about these custom types? This issue will be described below. 1. Structure 1. Declaration of structure 1.1 Basic knowledge of structures A structure is a collection of values called member variables. Each member of the […]

[C language] Custom types: unions and enumerations

Today I will share what I learned about unions and enumerations: 1. Declaration of union type 2. Characteristics of the consortium 3. Calculation of consortium 4. Declaration of enumeration types 5. Advantages of enumeration types 6. What are the uses of enumeration types? 1. Declaration of union type The declaration of union and structure are […]

Custom types – structures, unions, enumerations

Article directory Structure Structure declaration, variable creation and initialization Anonymous structure declaration self-referencing of structures structure member access operator Structure memory alignment Why does memory alignment exist? Modify the default alignment number Structure parameter passing Rank Bit segment application examples consortium Consortium application enumerate Comparison with #define Use of enumerations Structure A structure is a […]