"C" structure (1)

Source: Internet
Author: User

It's been a long time since I've been on a book with garlic.

Wrote a program to verify what the garlic Guest said

#include <stdio.h>typedefstructStudent {intAge ; floatheight; } student;structstuent {intAge ; floatheight; };structStudent gavin_belson={ About,165.4};//The first way of declaringintMain () {structStudent gregory={Wuyi,175.4};//second way of declaringStudent Amy, sheldon= { A,193.2}; Amy.age= +; Amy.height =172.2;//Third Way of declaringprintf"Amy is:%d%f\n", Amy.age, amy.height); printf ("Sheldon is:%d%f\n", Sheldon.age, sheldon.height); printf ("Gavin_belson is:%d%f\n", Gavin_belson.age, gavin_belson.height); printf ("Gregory is:%d%f\n", Gregory.age, gregory.height); return 0;}

Structs can be declared and defined outside of main, or they can be defined externally using TypeDef, or externally declared internally

The last student of a typedef can be followed by a square of curly braces, which can be identified by the compiler.

"C" structure (1)

Related Article

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.