In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to define c language structure type". In daily operation, I believe many people have doubts about how to define c language structure type. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about how to define the type of c language structure. Next, please follow the editor to study!
Definition of structure type
A structure type is a construction type that consists of different types of data items. Each data item that makes up a structure type is called a member of that structure type. When the structure type is used in the program, the structure type should be defined in the program first, that is, the composition of the structure should be explained.
General form of structure type definition
Struct structure type name
{
Data type member name 1
Data type member name 2
……
Data type member name n
}
Here is an example of a structure type definition:
Struct student
{
Int id; / / indicates the student number
Char name [20]; / / indicates name
Char gender// indicates gender
Double score / / indicates the score
}
Above, a structure type is defined to describe the basic information of students, which mainly includes: student number, name, gender and score. When defining the structure type, it is described by members of five different data types.
Structure type naming
It is important to note when defining the structure type:
(1) the structure type is defined using the keyword struct, followed by a custom structure type name.
Follow the naming convention for identifiers. These two parts make up the type name of the structure, for example, the type name of the above example is "struct student".
(2) each member of the structure is defined with a semicolon.
(3) the definition of the whole structure type also ends with a semicolon.
It should be noted that the definition of a structure type in the program is a new custom type described in the program, and no memory space is allocated to store the data. If you need to use structure types to process data, you also need to define variables of structure types in your program.
At this point, the study on "how to define the structure type of c language" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.