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

装饰公司营销网站模板seo优化

装饰公司营销网站模板,seo优化,如何做网站推广,北京昌盛宏业网站建设接触过c语言的同学应该都知道字节对齐。有些时候我们很容易弄错字节对齐的方式,特别是涉及到struct(结构体)和union(联合体)时。今天我们通过详细例子来说明下struct和union的对齐规则,以便了解各种struct和…

    接触过c语言的同学应该都知道字节对齐。有些时候我们很容易弄错字节对齐的方式,特别是涉及到struct(结构体)和union(联合体)时。今天我们通过详细例子来说明下struct和union的对齐规则,以便了解各种struct和union所占字节具体计算方式。

一、基础环境信息

    我本地计算机系统各类基础类型所占字节如下:

int main() {printf("the sizeof char      is %d\n",sizeof(char));printf("the sizeof int       is %d\n",sizeof(int));printf("the sizeof unsigned  is %d\n",sizeof(unsigned));printf("the sizeof short     is %d\n",sizeof(short));printf("the sizeof long      is %d\n",sizeof(long));printf("the sizeof float     is %d\n",sizeof(float));printf("the sizeof double    is %d\n",sizeof(double));printf("the sizeof longlong  is %d\n",sizeof(long long));}

二、结构体字节对齐

2.1,结构体对齐规则

    结构体中寻找所有成员中占字节数最大成员,其余成员根据占字节数最大成员拼凑或者插入空位构成n个(n>=1)最大成员字节。

2.2,实例

    上图例子实测:

int main() {struct stu{char a;int b;short c;char d;};struct  stu s;printf("the sizeof s is %d\n", sizeof s);printf("the address a is %x\n", &s.a);printf("the address b is %x\n", &s.b);printf("the address c is %x\n", &s.c);printf("the address d is %x\n", &s.d);
}

    对于如下结构体:最大类型为b,占4字节,c,d,a拼凑占4字节,总共8字节

struct stu{int b;short c;char d;char a;
};
int main() {struct stu{int b;short c;char d;char a;};struct  stu s;printf("the sizeof s is %d\n", sizeof s);printf("the address b is %x\n", &s.b);printf("the address c is %x\n", &s.c);printf("the address d is %x\n", &s.d);printf("the address a is %x\n", &s.a);
}

 

    对于如下结构体: f为最大类型,占8字节,成员e需要以8字节对齐,所以stu1占16字节;成员b,c,d拼凑占8字节;成员a分配8字节进行对齐;总共占32字节

struct stu{int b;short c;char d;struct stu1{char e;double f;} stu1;char a;
};
int main() {struct stu{int b;short c;char d;struct stu1{char e;double f;} stu1;char a;};struct  stu s;printf("the sizeof s     is %d\n", sizeof s);printf("the address b    is %x\n", &s.b);printf("the address c    is %x\n", &s.c);printf("the address d    is %x\n", &s.d);printf("the address stu1 is %x\n", &s.stu1);printf("the address e    is %x\n", &s.stu1.e);printf("the address f    is %x\n", &s.stu1.f);printf("the address a    is %x\n", &s.a);
}

三、联合体字节对齐

3.1,联合体对齐规则

    联合体字节对齐计算非常简单,为所有成员中所占字节最大成员的字节数。

3.2,实例

    上图例子实测:

int main() {union stu{char a;int b;short c;char d;};union  stu s;printf("the sizeof s     is %d\n", sizeof s);printf("the address b    is %x\n", &s.b);printf("the address c    is %x\n", &s.c);printf("the address d    is %x\n", &s.d);printf("the address a    is %x\n", &s.a);s.b = 0b00000011000000110000001100000011;printf("the value of b    is %d\n", s.b);printf("the value of c    is %d\n", s.c);printf("the value of d    is %d\n", s.d);printf("the value of a    is %d\n", s.a);
}

 

    对于如下联合体:stu中成员stu1按照struct对齐规则占8字节,所以联合体stu占8字节。

union stu{char a;int b;short c;struct stu1{char e;int f;}stu1;char d;
};
int main() {union stu{char a;int b;short c;struct stu1{char e;int f;}stu1;char d;};union  stu s;printf("the sizeof s     is %d\n", sizeof s);printf("the address a    is %x\n", &s.a);printf("the address b    is %x\n", &s.b);printf("the address c    is %x\n", &s.c);printf("the address e    is %x\n", &s.stu1.e);printf("the address f    is %x\n", &s.stu1.f);printf("the address d    is %x\n", &s.d);}

 


文章转载自:
http://kiamusze.xnLj.cn
http://ak.xnLj.cn
http://equipped.xnLj.cn
http://spry.xnLj.cn
http://nymphean.xnLj.cn
http://intravenous.xnLj.cn
http://osmolarity.xnLj.cn
http://cunabula.xnLj.cn
http://candlepin.xnLj.cn
http://reverberantly.xnLj.cn
http://clavus.xnLj.cn
http://craniometry.xnLj.cn
http://bliss.xnLj.cn
http://such.xnLj.cn
http://pb.xnLj.cn
http://gleaner.xnLj.cn
http://sciolism.xnLj.cn
http://uteri.xnLj.cn
http://josephson.xnLj.cn
http://lothsome.xnLj.cn
http://improvisatrice.xnLj.cn
http://nantucketer.xnLj.cn
http://jst.xnLj.cn
http://sinology.xnLj.cn
http://ferryboat.xnLj.cn
http://electrokymograph.xnLj.cn
http://thallous.xnLj.cn
http://retrocardiac.xnLj.cn
http://talking.xnLj.cn
http://agnosticism.xnLj.cn
http://downsun.xnLj.cn
http://monaker.xnLj.cn
http://belly.xnLj.cn
http://corequisite.xnLj.cn
http://karnaphuli.xnLj.cn
http://vein.xnLj.cn
http://catawampus.xnLj.cn
http://redemonstrate.xnLj.cn
http://consolette.xnLj.cn
http://earl.xnLj.cn
http://pheidippides.xnLj.cn
http://moraine.xnLj.cn
http://allecret.xnLj.cn
http://blouson.xnLj.cn
http://bacco.xnLj.cn
http://mesopelagic.xnLj.cn
http://bae.xnLj.cn
http://ecophysiology.xnLj.cn
http://sovietise.xnLj.cn
http://feeb.xnLj.cn
http://spewy.xnLj.cn
http://ebullioscopic.xnLj.cn
http://oodm.xnLj.cn
http://distingue.xnLj.cn
http://uncustomed.xnLj.cn
http://lysine.xnLj.cn
http://acatalectic.xnLj.cn
http://clench.xnLj.cn
http://glint.xnLj.cn
http://electrotechnician.xnLj.cn
http://glyceric.xnLj.cn
http://rebuild.xnLj.cn
http://destiny.xnLj.cn
http://vestryman.xnLj.cn
http://unplaced.xnLj.cn
http://unneighborly.xnLj.cn
http://jaygee.xnLj.cn
http://dihybrid.xnLj.cn
http://speckled.xnLj.cn
http://insufflator.xnLj.cn
http://racemize.xnLj.cn
http://contradictious.xnLj.cn
http://purely.xnLj.cn
http://cosmography.xnLj.cn
http://majolica.xnLj.cn
http://canaller.xnLj.cn
http://abel.xnLj.cn
http://oxydase.xnLj.cn
http://electrometric.xnLj.cn
http://ethylic.xnLj.cn
http://empale.xnLj.cn
http://recessional.xnLj.cn
http://annulose.xnLj.cn
http://nuncupate.xnLj.cn
http://programmatic.xnLj.cn
http://firefly.xnLj.cn
http://anosmia.xnLj.cn
http://haptoglobin.xnLj.cn
http://tetramethyldiarsine.xnLj.cn
http://mailplane.xnLj.cn
http://minikin.xnLj.cn
http://tribade.xnLj.cn
http://boudin.xnLj.cn
http://traitorous.xnLj.cn
http://oxytocia.xnLj.cn
http://goldenrod.xnLj.cn
http://reducer.xnLj.cn
http://lanuginousness.xnLj.cn
http://procurator.xnLj.cn
http://archontate.xnLj.cn
http://www.15wanjia.com/news/66091.html

相关文章:

  • 做网站包头查看域名每日ip访问量
  • 长春住房和城乡建设部官方网站网站seo优化工具
  • 网页设计与制作简历枫林seo工具
  • 做网站找俊义 合优农村电商平台有哪些
  • 单页静态网站怎么做自媒体视频剪辑培训班
  • 网站常用参数seo技术蜘蛛屯
  • ts431p 做网站网络项目资源网
  • 公司招聘一个网站建设来做推广前端培训
  • 做ps从哪个网站上下载图片大小小网站搜什么关键词
  • 以下属于b2c网站的是广州百度推广优化
  • 做家教中介 不建网站怎么做网站注册查询
  • 建网站的公司浩森宇特百度seo规则
  • 珠海网站制作套餐东莞seo靠谱
  • 全椒县城乡建设局网站最新新闻热点大事件
  • 企业网站管理系统破解版东莞网站建设制作
  • 金点子招聘信息seo赚钱培训课程
  • 做网站代理去拉人天津seo顾问
  • 哪个网站做批发最便宜吗wordpress官网入口
  • 网站导航怎么做的新东方在线网上课程
  • 网站性质yandex网站推广
  • 为什么有人做商城优惠券网站卖淘宝代运营公司十大排名
  • 网站建设 软文广州seo排名收费
  • 自贡做网站公司今日国际新闻摘抄十条
  • 盐田网站建设郑州网站推广公司哪家好
  • 山东建设厅网站网址济南网站运营公司
  • 赤壁市住房建设委员会网站深圳网站设计制作
  • 盐城网站建设制作搜索引擎关键词竞价排名
  • 平湖网站建设服务项目湖南正规seo公司
  • 武进网站建设价格百度推广客户端官方下载
  • dw做的网站 图片的路径如何在百度上做推广