C语言——enum
2024-08-27 20:42:50
#include<stdio.h>
enum Season
{
spring, summer=100, fall=96, winter
};
typedef enum
{
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}Weekday;
int main(void)
{
char * files[] = {"f","b","d","g"};
printf("sizeof files = %d\n",sizeof(files));
printf("sizeof int = %d\n",sizeof(int));
char *p = NULL;
printf("sizeof p = %d\n",sizeof(p));
/* Season */
printf("%d \n", spring); // 0
printf("%d, %c \n", summer, summer); // 100, d
printf("%d \n", fall+winter); // 193
enum Season mySeason=winter;
if(winter==mySeason)
printf("mySeason is winter \n"); // mySeason is winter
int x=100;
if(x == summer)
printf("x is equal to summer\n"); // x is equal to summer
printf("%d bytes\n", sizeof(spring)); // 4 bytes
/* Weekday */
printf("sizeof Weekday is: %d \n", sizeof(Weekday)); //sizeof Weekday is: 4
Weekday today = Saturday;
Weekday tomorrow;
if(today == Monday)
tomorrow = Tuesday;
else
tomorrow = (Weekday) (today + 1); //remember to convert from int to Weekday
return 0;
}
sizeof files = 16
sizeof int = 4
sizeof p = 4
0
100, d
193
mySeason is winter
x is equal to summer
4 bytes
sizeof Weekday is: 4
Terminated with return code 0
Press any key to continue ...
最新文章
- js中网页区域/正文/屏幕 宽和高
- MySQL 5.7 并行复制实现原理与调优
- 再看 AspriseOCR - OCR应用开发 -20151124
- 2013 duilib入门简明教程 -- 总结 (20)
- Mac OS X 删除文件快捷键
- 支持nmap批量漏洞扫描的script
- 客户端显示Not yet reported
- STL 源码分析《5》---- lower_bound and upper_bound 详解
- 【Java基础】Java内部类
- js控制select数据绑定下拉列表
- AspNetWebApi管线中如果定义两种类型的消息处理程序(全局/路由)
- QTP自动化测试培训:描述编程之WebElement
- LAP+mysql-主从+redis
- 运行Chromium浏览器缺少google api密钥无法登录谷歌账号的解决办法
- Java内存分配以及GC
- IntelliJ IDEA 使用技巧
- Atom使用
- Java 中常见的各种排序算法汇总
- acl的基本知识点
- Android Activity全面解析
热门文章
- Python";sorted()";和";.sort()";的区别
- C# 私有字段前缀 _ 的设置(VS2019, .editorconfig)
- Python3解leetcode Count Primes
- C#进阶系列——WebApi 路由机制剖析:你准备好了吗? 转载https://www.cnblogs.com/landeanfen/p/5501490.html
- ubuntu+qt+opencv
- 小程序中封装base64
- 判断是否是NaN
- spring 注释
- Linux崩溃时启动脚本获取进程相关信息
- excel vlookup的使用