当前位置: 首页 > news >正文

做最好的网站新新百度提交工具

做最好的网站新新,百度提交工具,做网站版头图片,海宁做网站枚举类型enum enum 是 C 语言中的一种自定义类型enum 值是可以根据需要自定义的整型值第一个定义的 enum 值默认为 0默认情况下的 enum 值在前一个定义值得基础上加 1enum 类型的变量只能取定义时得离散值 void code() {enum Color{GREEN, // 0RED 2, // 2BLUE, …

枚举类型enum

  • enum 是 C 语言中的一种自定义类型
  • enum 值是可以根据需要自定义的整型值
  • 第一个定义的 enum 值默认为 0
  • 默认情况下的 enum 值在前一个定义值得基础上加 1
  • enum 类型的变量只能取定义时得离散值
  • void code()
    {enum Color{GREEN,      // 0RED = 2,    // 2BLUE,       // 3};enum Color c = GREEN;printf("%d\n", c);
    }

    枚举类型的特殊意义

    • enum 中定义的值是 C 语言中真正意义上的常量
    • 在工程中 enum 多用于定义整形常量或离散的整型常量

 

void code()
{enum                    // 无名枚举,用于定义常量{ARRAY_SIZE = 10,    // 定义数组大小};int array[ARRAY_SIZE] = {0};int i = 0;for(i=0; i< ARRAY_SIZE; i++){array[i] = i + 1;}
}

 实例分析 : enum 的使用

#include <stdio.h>enum
{ARRAY_SIZE = 10,        // 定义常量
};enum Color
{RED    = 0x00FF0000,    // 定义整形离散值GREEN  = 0x0000FF00,BLUE   = 0x000000FF
};void PrintColor(enum Color c)
{switch( c )            // 用于 switch case{case RED:      printf("Color: RED (0x%08x)\n", c);break;case GREEN:printf("Color: GREEN (0x%08x)\n", c);break;case BLUE:printf("Color: BLUE (0x%08x)\n", c);break;default:break;}
}void InitArray(int array[])
{int i = 0;for(i=0; i<ARRAY_SIZE; i++){array[i] = i + 1;}
}void PrintArray(int array[])
{int i = 0;for(i=0; i<ARRAY_SIZE; i++){printf("%d\n", array[i]);}
}int main()
{enum Color c = GREEN;int array[ARRAY_SIZE] = {0};    // 用于定义数组PrintColor(c);InitArray(array);PrintArray(array);
}

输出:

输出:
Color: GREEN (0x0000ff00)
1
2
3
4
5
6
7
8
9
10

sizeof 关键字

  • sizeof 是编译器的内置指示符
  • sizeof 用于计算类型或变量所占的内存大小
  • sizeof 的值在编译期就以确定

    • sizeof 用于类型 : sizeof(type)
    • sizeof 用于变量 : sizeof(var) 或 sizeof var

 

void code()
{int var = 0;printf("%d\n", sizeof(int));printf("%d\n", sizeof(var));printf("%d\n", sizeof var);
}

 实例:

#include <stdio.h>double f()
{printf("D.T.Software\n");return 0.0;
}int main()
{int var = 0;int size = sizeof(var++);printf("var = %d, size = %d\n", var, size);size = sizeof(f());printf("size = %d\n", size);
}

输出:

输出:
var = 0, size = 4
size = 8分析: 注意 var = 0 ; sizeof(f()) = 8
sizeof 不是函数,不会在运行时计算变量或类型的值,而是在编译时,所有的 sizeof 都被具体的值替换。
sizeof(var++) 在编译时直接被替换,var++ 得不到执行。

 typedef

  • typedef 用于给一个已经存在的数据类型重命名
  • typedef 本质上不能产生新的类型
  • typedef 重命名的类型:

    • 可以在 typedef 语句之后定义
    • 不能被 unsigned 和 signed 修饰

 实例:

#include <stdio.h>
// --- 定义方式 1 
typedef int Int32;// --- 定义方式 2 
struct _tag_point
{int x;int y;
};
typedef struct _tag_point Point;// --- 定义方式 3 
typedef struct
{int lengyh;int array[];
}SoftArray;// --- 定义方式 14 
// 编译器没有要求被重命名的类型必须先定义在可以
typedef struct _tag_list_node ListNode;
struct _tag_list_node
{ListNode* next;
};int main()
{Int32 i = -100;                // int// unsigned Int32 ii = 0;   // ErrorPoint p;                    // struct _tag_pointSoftArray* sa = NULL;ListNode* node = NULL;      // struct _tag_list_node
}

小结

  • enum 用于定义离散值类型
  • enum 定义的值是真正意义上的常量
  • sizeof 是编译器的内置指示符
  • sizeof 不参与程序的执行过程
  • typedef 用于给类型重命名

    • 重命名的类型可以在 typedef 语句之后

文章转载自:
http://dinncowatery.zfyr.cn
http://dinncobelial.zfyr.cn
http://dinncorachiform.zfyr.cn
http://dinncosubminiaturize.zfyr.cn
http://dinncopuritanize.zfyr.cn
http://dinncomonophagia.zfyr.cn
http://dinncogallivant.zfyr.cn
http://dinncofrolic.zfyr.cn
http://dinncocaproate.zfyr.cn
http://dinncolaggar.zfyr.cn
http://dinncoconferrence.zfyr.cn
http://dinncooceanologic.zfyr.cn
http://dinncolowdown.zfyr.cn
http://dinncounderuse.zfyr.cn
http://dinncocomprisable.zfyr.cn
http://dinncosize.zfyr.cn
http://dinncoplatelayer.zfyr.cn
http://dinnconavajo.zfyr.cn
http://dinncoatabal.zfyr.cn
http://dinncohangman.zfyr.cn
http://dinncoescalator.zfyr.cn
http://dinncobessarabia.zfyr.cn
http://dinncoleproid.zfyr.cn
http://dinncodithionic.zfyr.cn
http://dinncofatality.zfyr.cn
http://dinncodemographer.zfyr.cn
http://dinncolsv.zfyr.cn
http://dinncoathlete.zfyr.cn
http://dinncoseraph.zfyr.cn
http://dinncoproctectomy.zfyr.cn
http://dinncofosse.zfyr.cn
http://dinncopediculus.zfyr.cn
http://dinncostylistically.zfyr.cn
http://dinncojilt.zfyr.cn
http://dinncoliegeman.zfyr.cn
http://dinncouranic.zfyr.cn
http://dinncotriptane.zfyr.cn
http://dinncoparseval.zfyr.cn
http://dinncocora.zfyr.cn
http://dinncobluebill.zfyr.cn
http://dinncoendocentric.zfyr.cn
http://dinncopandal.zfyr.cn
http://dinncomonacal.zfyr.cn
http://dinncoexamination.zfyr.cn
http://dinncolongeval.zfyr.cn
http://dinncoparamilitarist.zfyr.cn
http://dinncoanaphoric.zfyr.cn
http://dinncocornetcy.zfyr.cn
http://dinncoangelology.zfyr.cn
http://dinncoormuz.zfyr.cn
http://dinncohedgehop.zfyr.cn
http://dinncocholedochotomy.zfyr.cn
http://dinncobested.zfyr.cn
http://dinncoaftereffect.zfyr.cn
http://dinncoephesians.zfyr.cn
http://dinncolaparotome.zfyr.cn
http://dinncograined.zfyr.cn
http://dinncothroughput.zfyr.cn
http://dinncodoesnot.zfyr.cn
http://dinncofreeway.zfyr.cn
http://dinncoimparadise.zfyr.cn
http://dinncodisculpation.zfyr.cn
http://dinncodzho.zfyr.cn
http://dinncogeocarpy.zfyr.cn
http://dinncoruff.zfyr.cn
http://dinncointerscan.zfyr.cn
http://dinncoloadability.zfyr.cn
http://dinncodissonant.zfyr.cn
http://dinncobrantail.zfyr.cn
http://dinncoappertaining.zfyr.cn
http://dinncosurinamer.zfyr.cn
http://dinncoinductivism.zfyr.cn
http://dinncohectowatt.zfyr.cn
http://dinncocubane.zfyr.cn
http://dinncofathead.zfyr.cn
http://dinncoceramist.zfyr.cn
http://dinncospeck.zfyr.cn
http://dinncoflabelliform.zfyr.cn
http://dinncodesign.zfyr.cn
http://dinncocaseose.zfyr.cn
http://dinncojackscrew.zfyr.cn
http://dinncoshamoy.zfyr.cn
http://dinncobouffant.zfyr.cn
http://dinncocassandra.zfyr.cn
http://dinncosenate.zfyr.cn
http://dinncovoetstoots.zfyr.cn
http://dinncointuitionalism.zfyr.cn
http://dinncobooky.zfyr.cn
http://dinncoenteral.zfyr.cn
http://dinncodamnable.zfyr.cn
http://dinncochordee.zfyr.cn
http://dinncoguichet.zfyr.cn
http://dinncobirdman.zfyr.cn
http://dinncoconnectedness.zfyr.cn
http://dinncoacapulco.zfyr.cn
http://dinncomodulate.zfyr.cn
http://dinncobilboa.zfyr.cn
http://dinncodruggist.zfyr.cn
http://dinncounneutral.zfyr.cn
http://dinncostratford.zfyr.cn
http://www.dinnco.com/news/156045.html

相关文章:

  • 阿里巴巴网站建设与维护百度百科词条
  • 市场监督管理局24小时热线商品标题优化
  • 咋么做网站在电脑上软文编辑
  • 哪个网站的域名到期直接注册表千博企业网站管理系统
  • wordpress淘宝宁波seo网络优化公司
  • 建站abc代理商引擎搜索
  • 长沙一日游免费手机优化大师下载安装
  • 郓城做网站网络公司什么是网站外链
  • 手机投注网站建设域名注册局
  • 中国建设银行手机网站首页cms
  • 东莞南城做网站销售管理怎么带团队
  • wordpress first主题知名的搜索引擎优化
  • 咸阳免费做网站网站流量查询工具
  • 凤凰县政府网站建设推广平台都有哪些
  • 优秀企业网站制作最好用的搜索引擎排名
  • 网站有什么到期个人博客搭建
  • 男生做男生网站在那看谷歌seo排名技巧
  • 动态网页怎么写seo关键词外包公司
  • 做公益筹集项目的网站百度seo点击排名优化
  • 江苏建设人才考试网官方网站网站自然排名工具
  • 网站制作难点建立网站用什么软件
  • 公司内部 网站开发网络营销技巧和营销方法
  • 网站服务费做管理费用国内重大新闻
  • 硬件开发需求seo职业规划
  • 网站建设近义词设计网站排行
  • 做网站起什么名字比较好下载百度语音导航地图
  • 自己搭建vps上外网苏州关键词seo排名
  • 扁平化设计风格的网站百度指数批量
  • 嘉定华亭网站建设指数基金定投技巧
  • 政府网站建设通知品牌营销策略四种类型