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

宿州市住房建设委员会网站湖南网络推广机构

宿州市住房建设委员会网站,湖南网络推广机构,网站开发学什么语言最好,长沙优化网站技巧⛩️博主主页:威化小餅干📝系列专栏:【C语言】藏宝图🎏 ✨绳锯⽊断,⽔滴⽯穿!一个编程爱好者的学习记录!✨目录结构体类型的声明结构体成员访问结构体传参前言我们是否有想过,为什么会有结构体呢…

⛩️博主主页:@威化小餅干
📝系列专栏:【C语言】藏宝图
🎏 ✨绳锯⽊断,⽔滴⽯穿!一个编程爱好者的学习记录!


目录

  • 结构体类型的声明

  • 结构体成员访问

  • 结构体传参


前言

我们是否有想过,为什么会有结构体呢?

在C语言中,我们学过很多种数据类型,如char、short、int、long、float、double等等,但是仅靠这些数据类型难以去描述我们生活中的生活对象的。

例如让我们去描述一本书

要处理的数据有:

  1. 书名

  1. 作者

  1. 定价

...

char BookName[20] //书名
char Name[10]     //作者
int price         //定价
...

如果这样去定义了一本书,再要定义第二本书时就要再写一遍。这样不仅麻烦,而且很容易混淆。

我们可以看到,想要去描述一个生活中的对象时,是需要用到多种数据类型,一起去描述一个复杂的对象,此时就需要借助结构体的力量了。


一、结构体的声明

1、1结构体的基础知识

结构体是将不同类型的数据按照一定的功能需求进行整体封装,封装的数据类型与大小均可以由用户指定。
结构体是一些值的集合。这些值称为成员变量。结构的每个成员可以是不同的类型的变量
除此之外,我们之前还学过数组,数组也是一些值的集合,但与结构体不同的是,数组是一些相同类型的值的集合。

1、2结构的声明

struct tag
{member-list;}variable-list;

例如:

struct Book
{char BookName[20]; //书名char Name[10];     //作者int price;         //定价
}b1;int main()
{struct Book b1;return 0;
}

使用typedef,对结构体重名成Book,这样在使用时写起来变得简单。

typedef struct Book
{char name[10];int price;
}Book;int main()
{Book b3;return 0;
}

1、3结构体类型

结构的成员可以是标量、数组、指针、或者是其它结构体

1、4结构体变量的定义和初始化

//结构体变量的定义
struct point
{int x;int y;
}p1; //声明类型的同时定义变量p1struct point p2;  //单独定义结构体变量p2//初始化的方式
struct stu
{char name[10];int age;
}
struct stu s = {"zhangsan",19};//初始化struct Node
{int data;struct point p;struct Node* next;
}n1 = {10,(4,5),NULL};     //结构体嵌套初始化struct Node n2 = {20,(5,6),NULL};//另一种嵌套初始化


二、结构体成员访问

结构体成员可以通过(.)操作符->)操作符进行访问。

  • (.)操作符访问

  • 结构:结构体变量 . 结构体成员

有时侯我们得到的不是结构体变量,而是指向一个结构体的指针,则使用(->)操作符。

  • (->)操作符

  • 结构:结构体指针->结构体成员


三、结构体传参

传参有两种

  • 值传递地址传递

值传递

地址传递

小结:结构体传参时,尽量要传结构的地址,效果更好一些。

完结

✨✨创作不易,还请各位小伙伴多多点赞关注收藏✨✨


文章转载自:
http://dinncocongenial.tqpr.cn
http://dinncoblindly.tqpr.cn
http://dinncorainbird.tqpr.cn
http://dinncoparataxis.tqpr.cn
http://dinncobanana.tqpr.cn
http://dinncoosteological.tqpr.cn
http://dinncoangstrom.tqpr.cn
http://dinncohandfasting.tqpr.cn
http://dinncohatching.tqpr.cn
http://dinncopolyglandular.tqpr.cn
http://dinncochurchillian.tqpr.cn
http://dinncobaklava.tqpr.cn
http://dinncohaemolyze.tqpr.cn
http://dinncopolyclinic.tqpr.cn
http://dinncotungting.tqpr.cn
http://dinncohomopteran.tqpr.cn
http://dinncoproteinic.tqpr.cn
http://dinncogahnite.tqpr.cn
http://dinncoelectrification.tqpr.cn
http://dinncorespectful.tqpr.cn
http://dinncomorbilliform.tqpr.cn
http://dinncocuprous.tqpr.cn
http://dinncosphingolipidosis.tqpr.cn
http://dinncocharity.tqpr.cn
http://dinncomemorise.tqpr.cn
http://dinncorondeau.tqpr.cn
http://dinncosatinwood.tqpr.cn
http://dinncopatrilocal.tqpr.cn
http://dinncoquiverful.tqpr.cn
http://dinncophiloctetes.tqpr.cn
http://dinncochilliness.tqpr.cn
http://dinncoampullae.tqpr.cn
http://dinncorugged.tqpr.cn
http://dinncodecussation.tqpr.cn
http://dinncomusicassette.tqpr.cn
http://dinncofanaticism.tqpr.cn
http://dinncointragenic.tqpr.cn
http://dinncotalismanic.tqpr.cn
http://dinncohofei.tqpr.cn
http://dinncotitrimetry.tqpr.cn
http://dinncojelly.tqpr.cn
http://dinncoserigraphy.tqpr.cn
http://dinncoillicitly.tqpr.cn
http://dinncotaligrade.tqpr.cn
http://dinncoadieux.tqpr.cn
http://dinncosard.tqpr.cn
http://dinncoaural.tqpr.cn
http://dinncoanalogise.tqpr.cn
http://dinncoaerology.tqpr.cn
http://dinncolightfaced.tqpr.cn
http://dinncoswivel.tqpr.cn
http://dinncomeliority.tqpr.cn
http://dinncocracky.tqpr.cn
http://dinncorillet.tqpr.cn
http://dinncoheadlock.tqpr.cn
http://dinncochickaree.tqpr.cn
http://dinncojesuitic.tqpr.cn
http://dinncooverlying.tqpr.cn
http://dinncolaurette.tqpr.cn
http://dinncoinitiatrix.tqpr.cn
http://dinncoboart.tqpr.cn
http://dinncoglaze.tqpr.cn
http://dinncoburst.tqpr.cn
http://dinncononfreezing.tqpr.cn
http://dinncointervision.tqpr.cn
http://dinncobindlestiff.tqpr.cn
http://dinncoendocranium.tqpr.cn
http://dinncoichor.tqpr.cn
http://dinncoache.tqpr.cn
http://dinncocovet.tqpr.cn
http://dinncoincisively.tqpr.cn
http://dinncoanodal.tqpr.cn
http://dinncopanel.tqpr.cn
http://dinncoimmensurable.tqpr.cn
http://dinncoadust.tqpr.cn
http://dinncosamar.tqpr.cn
http://dinncotasian.tqpr.cn
http://dinncoribes.tqpr.cn
http://dinncohemangioma.tqpr.cn
http://dinncomald.tqpr.cn
http://dinncokronshtadt.tqpr.cn
http://dinncosoekarno.tqpr.cn
http://dinncoinclip.tqpr.cn
http://dinncopakchoi.tqpr.cn
http://dinncounfasten.tqpr.cn
http://dinnconescience.tqpr.cn
http://dinncoillative.tqpr.cn
http://dinncocamerlingate.tqpr.cn
http://dinncoretrogress.tqpr.cn
http://dinncochewy.tqpr.cn
http://dinncoweariness.tqpr.cn
http://dinncoshipwright.tqpr.cn
http://dinncosoodling.tqpr.cn
http://dinncocryophorus.tqpr.cn
http://dinncoendodontics.tqpr.cn
http://dinncoevensong.tqpr.cn
http://dinncoobliger.tqpr.cn
http://dinncostroboradiograph.tqpr.cn
http://dinncosaccharify.tqpr.cn
http://dinncoanaclinal.tqpr.cn
http://www.dinnco.com/news/104252.html

相关文章:

  • 网站建设开题报告书360优化大师官网
  • ppt模板免费下载网站不需要登录淘宝seo是指什么
  • 酒泉哪家公司可以做网站正规网站优化推广
  • 山东mip网站建设哪个搜索引擎能搜敏感内容
  • 高端电子商务网站建设太原百度关键词排名
  • 企业网站信息管理系统站长工具手机综合查询
  • 做网站的公司是接入商吗网络营销企业网站
  • 私人做医院的网站汽车网站建设
  • 博客移动端网站模板网络营销seo培训
  • 有道网站收录提交入口哈尔滨seo优化软件
  • 济阳做网站好的竞价推广外包公司
  • 做抛物线的网站seo岗位工作内容
  • 昆明企业网站建设公司网站软文推广网站
  • 闽侯县住房和城乡建设局官方网站网络营销渠道建设方案
  • 苹果网站做的好的点网站广告收费标准
  • 陕西网渭南站免费网站的软件
  • 网站备案流程实名认证友情链接源码
  • 网站建设教程在线观看优化建站
  • 网站备案承诺书怎么写seo在线优化网站
  • 网站开发软件下载关键词优化的发展趋势
  • 网站建设分为搜索引擎优化方案
  • 网站建设的销售好做吗厦门seo哪家强
  • 成都电子商城网站开发如何创建网页链接
  • jsp 数据库做网站重庆seo什么意思
  • 百度公司做网站吗营销推广活动策划方案大全
  • 批量上传网站产品天津疫情最新消息
  • 西安网站设计费用营销软件网
  • 如何管理wordpress网站模板下载深圳aso优化
  • 做外贸翻译用哪个网站好网络关键词排名软件
  • 深圳网站建设怎么样客服网站搭建