当前位置:网站首页>C language elementary level (IX) enumeration
C language elementary level (IX) enumeration
2022-06-21 13:22:00 【Princess Kaka】
One . Constant symbolization
1.const
const double PI = 3.1415926;
// week
const int SUN = 0;
const int MON = 1;
const int TUES = 2;
const int WED = 3;
const int THUR = 4;
const int FRI = 5;
const int SAT = 6;2.#define
#define PI 3.1415926
// week
#define SUM 0
#define MON 1
#define TUES 2
#define WED 3
#define THUR 4
#define FRI 5
#define SAT 63. enumeration
Scope
#include <stdio.h>
void func (){
#define N 12
const int n = 12;
}
int main(){
printf("%d\n",N);
//printf("%d\n",n);
}Two . enumeration
1. What is it?
Enumeration is a user-defined data type , Enumeration can regard as Is a set of macro definitions .
2. How to use it?
enum Enumeration type name { name 0, name 1, name 2,..., name n}; The names in the enumeration braces are constant symbols , The type is int, Value in turn from 0 To n.
Enumeration is to give these constant values , Specify a name .
Enumerators can be used directly as values .
Enumeration types can be used directly as types .
#include <stdio.h>
enum Mouth{Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sept,Oct,Nov,Dec};
int month_days[]={31,28,31,30,31,30,31,31,30,31,30,31};
char* month_names[]={" January "," February "," March "," April "," May "," June "," July "," August "," September "," October "," November "," December "};
void PrintMonth(enum Mouth m){
printf("%s Yes %d God \n",month_names[m],month_days[m]);
}
void main(){
enum Mouth m = Jan;
PrintMonth(m);
}You can specify values when declaring enumerations
// Commonly used system
enum Radix{Bin=2,Oct=8,Dec=10,Hex=16};You can also use one of these values , The following values are added successively 1
enum Mouth{Jan=1,Feb,Mar,Apr,May,Jun,Jul,Aug,Sept,Oct,Nov,Dec};边栏推荐
- 百问百答第43期:应用性能探针监测原理-PHP探针
- Memcached (high performance memory object cache)
- 『忘了再学』Shell流程控制 — 35、多分支case条件语句
- 7. pointer
- 小程序直播互动功能运行在App里?
- Setting of Seaborn drawing style
- 咨询:微证券是什么证券公司,开户安全吗?
- What does cloud desktop mean? What is the difference with fortress machine?
- [course assignment] floating point operation analysis and precision improvement
- 塔米狗项目解读:济宁华源项目管理有限公司34%股权转让
猜你喜欢

seaborn绘图风格的设置

SCCM基于已安装的 APP创建客户端集合并定期推送应用更新

【深入理解TcaplusDB技术】TcaplusDB构造数据

Deep learning practice (10): 3D medical image segmentation using pytorch
![[untitled]](/img/3c/c34a8cbbe398cecd54050b30f95b66.png)
[untitled]
![[deeply understand tcapulusdb technology] tmonitor system upgrade](/img/ec/bbfb7e2f19a94b69ec0a6092fd3032.png)
[deeply understand tcapulusdb technology] tmonitor system upgrade

Not only zero:bmtrain technology principle analysis

基于STM32电压检测和电流检测

还在用generator生成xxx管理系统的CRUD代码?来看看我是怎么写的

Matplotlib drawing tips
随机推荐
Cvpr2022 | the action sequence verification task was first proposed by X xiaohongshu of Shanghai University of science and technology, which can be applied to multiple scenarios such as scoring of spo
Memcached(高性能内存对象缓存)
Kubernetes' fast practice and core principle analysis
Repair for a while, decisively reconstruct and take responsibility -- talk about CRM distributed cache optimization
Are you still using generator to generate crud code of XXX management system? Let's see what I wrote
2022年中国手机银行年度专题分析
Deep learning practice (10): 3D medical image segmentation using pytorch
uva11991
启牛商学院app下载证券开户,是安全的吗?有风险嘛?
Two common schemes for handling interface idempotence
Kubernetes快速实战与核心原理剖析
实践 DevOps 时,可能面临的六大挑战
Data type classification supported by postgre SQL
5000字解析:实战化场景下的容器安全攻防之道
漫谈公网网络延迟
3. function improvement
Memcached (high performance memory object cache)
7. pointer
Explanation of common mesh generation methods in workbench
Analysis on the wallet system architecture of Baidu trading platform