当前位置:网站首页>C constant, cannot be changed

C constant, cannot be changed

2022-06-12 14:51:00 Leg hair Ger

C In language, constants are divided into

1 Literal constants

2 const Modified constant variable

3 #define Defined identifier constant

4 Enumeration constants

// In brackets MALE,FEMALE,SECRET It's an enumeration constant

        enum Sex {

               MALE,

                FEMALE,

                SECRET

                 };   

The default of enumeration constants is from 0 Start , Increase in descending order 1 Of     namely 0  1  2

// Literal constants

         3.14;// Literal constants    1000;// Literal constants      

//const Modified constant variable

         const float pai = 3.14f; // there pai yes const Modified constant variable ,

stay C In language, variables are limited only at the grammatical level pai Can't be changed directly , however pai Is essentially a variable , So it's called a constant variable .

         pai = 5.14;// It can't be modified directly !

//#define The identifier constant for

         #define MAX 100

原网站

版权声明
本文为[Leg hair Ger]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121442257698.html