Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the structure struct

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report