[C language-8] enum enum

Source: Internet
Author: User

Enumeration is a basic data type in C language, not a data structure

Used to declare a set of constant 1. How to enumerate variables in 3 A. Define the type first, and then define the variable B. Define both the type and the variable C. Anonymous definition enum Season {spring, Summer, Autumn, winter};enum Season s = spring; Variable names that have been positioned as enumerations cannot be used as other variable int Spring = 44;//error 2. The default value is a positive integer value from 0 to n enum {Spring, Summer, autumn=11, winter=55}; The same value is not recommended Directly using the enumeration value name, is actually the integer data printf ("%d\n", Summer);//2 The default value is an integer that increments from 0, and if an enumeration value is specified, the next default enumeration value is incremented from this value.

[C language-8] enum enum

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.