What is the structure struct
This article mainly explains "what is the structural struct". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the structural struct".
Catalogue
Why do you need to introduce structures?
Struct
Define
Typedef and # define
Initialization of structural variables and member access
Structure access
Why do you need to introduce structures?
The original data type can not meet the requirements, so the construction type structure is designed.
Struct defines struct name {basic type structure member}
1. Nameless structural type
two。 Named structural type
Struct student {char name [30]; char sex; int age; float high;} stu;struct student stu2
3. Alias constructor type
Typedef struct student {char name [30]; char sex; int age; float high;} STUDENT;STUDENT stu, stu2;typedef and # define
Typedef is a keyword commonly used to alias the structure, and the resulting statement participates in compilation, while the macro defined by # define has been processed in the preprocessing stage.
Initialization of structural variables and member access
Initialization is a special syntax that is not equivalent to assignment.
All basic types can be initialized either when they are defined or before initialization.
All construction types are either initialized at the time of definition, or members are defined first and then assigned to different underlying data types.
Structure access
Dot member operator.
Point to the member operator-> or (*).
Struct student * pst = & stpst.age (* pst) .agest.age thank you for your reading. The above is the content of "what is structural struct". After the study of this article, I believe you have a deeper understanding of what structural struct is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!