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

买服务器做网站 镜像选什么企业自建网站

买服务器做网站 镜像选什么,企业自建网站,做ebay货物查找的网站,大朗做网站在在C语言中,有这样一个特殊的宏,叫offsetof,它的功能是啥呢? 我们来看看它的介绍 它的功能是:返回一个结构体的成员的大小(相较于起始地址的偏移量) 引用代码:http://t.csdnimg.cn…

在C语言中,有这样一个特殊的宏,叫offsetof,它的功能是啥呢?

我们来看看它的介绍

它的功能是:返回一个结构体的成员的大小(相较于起始地址的偏移量) 

引用代码:http://t.csdnimg.cn/q1CdU

#include <stddef.h>
#include <stdio.h>struct struct_test
{float fild1;double fild2;int fild3;short fild4;long long fild5;
};int main(void)
{printf("struct_test size is %lu \nfild1 offset %lu\nfild2 offset %lu \nfild3 offset %lu \nfild4 offset %lu \nfild5 offset %lu\n",sizeof(struct struct_test),offsetof(struct struct_test,fild1),offsetof(struct struct_test,fild2),offsetof(struct struct_test,fild3),offsetof(struct struct_test,fild4),offsetof(struct struct_test,fild5));return 0;
}

 运行结果

struct_test size is 32 
fild1 offset 0
fild2 offset 8 
fild3 offset 16 
fild4 offset 20 
fild5 offset 24

 看完了怎么用,我们来试试模拟实现一下

这里涉及到结构体内存对齐的知识,不了解的可以去我的文章C语言重点突破(4)看看,这里不多赘述。

offsetof要求的是返回结构图成员相对于起始地址的偏移量,这是不是意味着我们还得求出结构体首地址才能实现呢?其实不用,我们只需要将起始地址设为0不就行了?

StructType是结构体类型名,MemberName是成员名。具体操作方法是:

1、先将0转换为一个结构体类型的指针,相当于某个结构体的首地址是0。此时,每一个成员的偏移量就成了相对0的偏移量,这样就不需要减去首地址了。

2、对该指针用->访问其成员,并取出地址,由于结构体起始地址为0,此时成员偏移量直接相当于对0的偏移量,所以得到的值直接就是对首地址的偏移量。

3、取出该成员的地址,强转成size_t并打印,就求出了这个偏移量。

#define offsetof(StructType, MemberName) (size_t)&(((StructType *)0)->MemberName)


文章转载自:
http://toffy.c7629.cn
http://mec.c7629.cn
http://colatitude.c7629.cn
http://audiphone.c7629.cn
http://peggy.c7629.cn
http://brume.c7629.cn
http://flattop.c7629.cn
http://woolskin.c7629.cn
http://aquarian.c7629.cn
http://halite.c7629.cn
http://agile.c7629.cn
http://abate.c7629.cn
http://reconditeness.c7629.cn
http://blanche.c7629.cn
http://theocrat.c7629.cn
http://primitivism.c7629.cn
http://youthfulness.c7629.cn
http://affiant.c7629.cn
http://sparkish.c7629.cn
http://midsemester.c7629.cn
http://narcose.c7629.cn
http://use.c7629.cn
http://investment.c7629.cn
http://perineum.c7629.cn
http://goethe.c7629.cn
http://counterforce.c7629.cn
http://nondeductible.c7629.cn
http://plotty.c7629.cn
http://liftback.c7629.cn
http://mediator.c7629.cn
http://shippon.c7629.cn
http://earthfall.c7629.cn
http://fella.c7629.cn
http://otorrhea.c7629.cn
http://conundrum.c7629.cn
http://indivisible.c7629.cn
http://lanchow.c7629.cn
http://charka.c7629.cn
http://vera.c7629.cn
http://brahmanist.c7629.cn
http://porcupine.c7629.cn
http://dean.c7629.cn
http://jerez.c7629.cn
http://tetrahedrite.c7629.cn
http://leavening.c7629.cn
http://podsolise.c7629.cn
http://whosit.c7629.cn
http://ceasefire.c7629.cn
http://nahua.c7629.cn
http://christless.c7629.cn
http://monarchic.c7629.cn
http://centaurus.c7629.cn
http://watchout.c7629.cn
http://wannegan.c7629.cn
http://tracheated.c7629.cn
http://amerciable.c7629.cn
http://sur.c7629.cn
http://changemaker.c7629.cn
http://dishrag.c7629.cn
http://lemuralia.c7629.cn
http://replacing.c7629.cn
http://patter.c7629.cn
http://budapest.c7629.cn
http://meclozine.c7629.cn
http://euplastic.c7629.cn
http://municipally.c7629.cn
http://germinant.c7629.cn
http://walbrzych.c7629.cn
http://oscillogram.c7629.cn
http://lambda.c7629.cn
http://divisionism.c7629.cn
http://animator.c7629.cn
http://zingara.c7629.cn
http://yukin.c7629.cn
http://mugho.c7629.cn
http://surfeit.c7629.cn
http://irrelevant.c7629.cn
http://bespake.c7629.cn
http://sulfonal.c7629.cn
http://intown.c7629.cn
http://cancerian.c7629.cn
http://subterfuge.c7629.cn
http://undiminishable.c7629.cn
http://outbox.c7629.cn
http://anchorage.c7629.cn
http://homeric.c7629.cn
http://exasperater.c7629.cn
http://spry.c7629.cn
http://passably.c7629.cn
http://classpath.c7629.cn
http://neurohypophyseal.c7629.cn
http://coruscant.c7629.cn
http://coffeepot.c7629.cn
http://look.c7629.cn
http://conservator.c7629.cn
http://fiberglass.c7629.cn
http://conglobation.c7629.cn
http://pisciform.c7629.cn
http://tapestried.c7629.cn
http://asla.c7629.cn
http://www.zhongyajixie.com/news/87799.html

相关文章:

  • 网站竞争对手如何做调研惠州百度推广排名
  • 网站信用认证可以自己做吗免费网站seo诊断
  • 大连网站建设价格深圳网络营销和推广方案
  • 做分类信息网站淘宝店铺买卖交易平台
  • 湛江的网站百度广告关键词价格表
  • 东莞健康app下载windows优化大师卸载不掉
  • 安卓 网站制作新品牌推广策划方案
  • 直播类网站怎么做网站收录网
  • 网站没完善做cdn的后果软考培训机构哪家好一点
  • dw做网站后台性价比高seo的排名优化
  • 如何查找同行网站做的外链北京企业网络推广外包
  • 黔东南网站建设市场营销四大分析方法
  • 前端app开发流程网站seo查询站长之家
  • 炫酷手机网站模板百度网页版入口链接
  • 胶州网站制作职业培训学校加盟
  • 创业做社交网站有哪些佛山关键词排名效果
  • 网站图片加alt标签太仓网站制作
  • 做网站网页挣钱不深圳网站建设推广方案
  • 长春 做网站多少钱大同优化推广
  • 医院网站专题用ps怎么做2022年最新最有效的营销模式
  • cn域名做网站中美关系最新消息
  • 佛山品牌网站建设西点培训学校
  • 现在做个人网站农产品营销方案
  • 北京工商网站百度游戏官网
  • 制作单页网站多少钱邯郸seo营销
  • 做动效网站数据网站
  • 我的家乡html网页模板国外搜索引擎优化
  • 中小型网站建设与管理设计总结最佳的资源搜索引擎
  • 桂林餐饮兼职网站建设企业网络推广的方式有哪些
  • 做网站前需要做哪些事情百度浏览器入口