Variable struct in C: struct typedef

Source: Internet
Author: User
Zookeeper

The code shows several types of struct in the past few days. The structure declaration is as follows:

Struct book {

String name;

Int price;

Int num;

};

The format of this structure definition structure variable is as follows:

Struct book student;


Struct book {

String name;

Int price;

Int num;

} Student;

This form indicates that the process of declaring the structure and the process of defining the structure variables are merged into one step.


Typedef struct (book) {// book can be omitted

String name;

Int price;

Int num;

} Student;

Typedef is used to create a name for an existing type. The format of the struct variable defined for this structure is: Student;



I personally think that the last one is more convenient in writing, When you define a large number of struct variables in the program.

Zookeeper

Variable struct in C: struct typedef

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.