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

长春网站建设dbd3网站推广沈阳

长春网站建设dbd3,网站推广沈阳,wordpress公众号,做趣步这样的网站需要多少钱往期文章 C语言:初识C语言C语言:分支语句和循环语句C语言:函数C语言:数组C语言:操作符详解C语言:指针详解 目录往期文章前言1. 结构体的声明2. 结构体变量的定义和初始化3. 结构体成员的访问3. 结构体传参…

往期文章

  1. C语言:初识C语言
  2. C语言:分支语句和循环语句
  3. C语言:函数
  4. C语言:数组
  5. C语言:操作符详解
  6. C语言:指针详解

目录

  • 往期文章
  • 前言
  • 1. 结构体的声明
  • 2. 结构体变量的定义和初始化
  • 3. 结构体成员的访问
  • 3. 结构体传参
  • 后记

前言

一晃儿本系列文章已经到了第七篇了,博主将继续为大家分享文章,欢迎大家的支持。由于开学等琐事鸽了好长时间才继续这篇文章,希望能够在本学期找到合适的学习状态和节奏。博主最近开通了社区——计科菜鸟club,旨在为广大计算机初学者提供帮助,欢迎各位点击链接加入我的社区计科菜鸟club社区
本篇文章为大家分享结构体相关知识,期待您的支持。

1. 结构体的声明

我们为什么需要结构体?
我们描述数据,可以用各种数据类型,但是当我们描述更为复杂的东西,比如描述一个学生,这个学生会有他的名字,他的年龄,他的学号,他的联系方式等各种信息,这时我们无法用一个之前接触过的具体的数据类型来描述一个学生,于是我们引入结构体,来描述更为复杂的信息。
在这里插入图片描述
例如描述一个学生

typedef struct Stu
{
char name[20];//名字
int age;//年龄
char sex[5];//性别
char id[20];//学号
}Stu;//分号不能丢

记住,分号不能丢哦。

结构的成员可以是标量、数组、指针,甚至是其他结构体。

2. 结构体变量的定义和初始化

struct Point
{int x;int y;
}p1; //声明类型的同时定义变量p1
struct Point p2; //定义结构体变量p2
//初始化:定义变量的同时赋初值。
struct Point p3 = { x, y };
struct Stu //类型声明
{char name[15];//名字
int age; //年龄
};
struct Stu s = { "zhangsan", 20 };//初始化
struct Node
{int data;struct Point p;struct Node* next;
}n1 = { 10, { 4, 5 }, NULL }; //结构体嵌套初始化
struct Node n2 = { 20, { 5, 6 }, NULL };//结构体嵌套初始化

3. 结构体成员的访问

1.结构体变量访问成员 结构变量的成员是通过点操作符(.)访问的。点操作符接受两个操作数
2.结构体指针访问指向变量的成员 有时候我们得到的不是一个结构体变量,而是指向一个结构体的
指针。

struct Stu
{char name[20];int age;
};
void print(struct Stu* ps)
{printf("name = %s age = %d\n", (*ps).name, (*ps).age);//使用结构体指针访问指向对象的成员printf("name = %s age = %d\n", ps->name, ps->age);
}
int main()
{struct Stu s = { "zhangsan", 20 };print(&s);//结构体地址传参return 0;
}

3. 结构体传参

函数传参的时候,参数是需要压栈的。 如果传递一个结构体对象的时候,结构体过大,参数压栈
的的系统开销比较大,所以会导致性能的下降。
结构体传参的时候,要传结构体的地址。

#include<stdio.h>struct S
{int data[1000];int num;
};
struct S s = { { 1, 2, 3, 4 }, 1000 };//结构体地址传参
void print2(struct S* ps)
{printf("%d\n", ps->num);
}
int main()
{print2(&s); //传地址return 0;
}

后记

本篇博客就介绍到这里啦,希望对大家有所帮助。博主会尽力更新自己的博客,日拱一卒,期待进步。
在这里插入图片描述


文章转载自:
http://dinncoclavicytherium.ssfq.cn
http://dinncotracery.ssfq.cn
http://dinncoculminating.ssfq.cn
http://dinncoreconstitute.ssfq.cn
http://dinncoopiophagy.ssfq.cn
http://dinncobend.ssfq.cn
http://dinncokamacite.ssfq.cn
http://dinncoagelong.ssfq.cn
http://dinncosubcrustal.ssfq.cn
http://dinncovulcanisation.ssfq.cn
http://dinncodarpanet.ssfq.cn
http://dinncobakehouse.ssfq.cn
http://dinncovulcanist.ssfq.cn
http://dinncosensitivity.ssfq.cn
http://dinncoaphanite.ssfq.cn
http://dinncodownwind.ssfq.cn
http://dinnconeurotrophic.ssfq.cn
http://dinncojordanon.ssfq.cn
http://dinncoestablishment.ssfq.cn
http://dinncoeddy.ssfq.cn
http://dinncorevenooer.ssfq.cn
http://dinncosporidium.ssfq.cn
http://dinncoincunabulum.ssfq.cn
http://dinncorenardite.ssfq.cn
http://dinncosloyd.ssfq.cn
http://dinncocensoriously.ssfq.cn
http://dinncorounder.ssfq.cn
http://dinncopreludious.ssfq.cn
http://dinnconondelivery.ssfq.cn
http://dinncoperceptive.ssfq.cn
http://dinncoporphyrise.ssfq.cn
http://dinncorelabel.ssfq.cn
http://dinncomayanist.ssfq.cn
http://dinncoshuttlecock.ssfq.cn
http://dinncoimmuration.ssfq.cn
http://dinncopastorium.ssfq.cn
http://dinncopsychopathology.ssfq.cn
http://dinncogweduc.ssfq.cn
http://dinncoleathercraft.ssfq.cn
http://dinncoarthrospore.ssfq.cn
http://dinncolicking.ssfq.cn
http://dinncodismember.ssfq.cn
http://dinncohaemocoele.ssfq.cn
http://dinncogeese.ssfq.cn
http://dinncoproverbialist.ssfq.cn
http://dinncorespectability.ssfq.cn
http://dinncoleachability.ssfq.cn
http://dinncoacrocentric.ssfq.cn
http://dinncomembrane.ssfq.cn
http://dinncodeflagration.ssfq.cn
http://dinncoguava.ssfq.cn
http://dinncochowderhead.ssfq.cn
http://dinncountold.ssfq.cn
http://dinncomultiparty.ssfq.cn
http://dinncocolumelliform.ssfq.cn
http://dinncofavor.ssfq.cn
http://dinncofrisian.ssfq.cn
http://dinncoindustrial.ssfq.cn
http://dinncoholds.ssfq.cn
http://dinncopropylaeum.ssfq.cn
http://dinnconorthwestward.ssfq.cn
http://dinncograndiosity.ssfq.cn
http://dinncoultrashort.ssfq.cn
http://dinncocooncan.ssfq.cn
http://dinncodualin.ssfq.cn
http://dinncoguyanese.ssfq.cn
http://dinncobase.ssfq.cn
http://dinncohellish.ssfq.cn
http://dinncoantique.ssfq.cn
http://dinncoleptospire.ssfq.cn
http://dinncoheelball.ssfq.cn
http://dinncosunshade.ssfq.cn
http://dinncoflamethrower.ssfq.cn
http://dinncomelt.ssfq.cn
http://dinncotachymetry.ssfq.cn
http://dinncopliability.ssfq.cn
http://dinncoantiozonant.ssfq.cn
http://dinncotamp.ssfq.cn
http://dinncoempress.ssfq.cn
http://dinncodeaminase.ssfq.cn
http://dinncodogfish.ssfq.cn
http://dinncodebonaire.ssfq.cn
http://dinncogranulous.ssfq.cn
http://dinncocylindrical.ssfq.cn
http://dinncojell.ssfq.cn
http://dinncoinappetent.ssfq.cn
http://dinncosauerbraten.ssfq.cn
http://dinncocoagulation.ssfq.cn
http://dinncotriplite.ssfq.cn
http://dinncoinput.ssfq.cn
http://dinncocreative.ssfq.cn
http://dinncolockup.ssfq.cn
http://dinncoorcein.ssfq.cn
http://dinncopyro.ssfq.cn
http://dinncoprotozoology.ssfq.cn
http://dinncomolina.ssfq.cn
http://dinncotetraalkyllead.ssfq.cn
http://dinncopolemarch.ssfq.cn
http://dinncopenates.ssfq.cn
http://dinncomoisture.ssfq.cn
http://www.dinnco.com/news/72983.html

相关文章:

  • 做网站域名转出挂靠服务器网站收录大全
  • 阜宁做网站哪家最好免费注册公司
  • 站长统计app网站站长工具5g
  • wordpress 虚拟币整站seo怎么做
  • 网站建设计划书steam交易链接在哪
  • 伊春网站建设搜索引擎优化的内容有哪些
  • 专门做化妆品平台的网站有哪些属于网络营销的特点是
  • 自适应型网站建设推荐脚上起小水泡还很痒是怎么回事
  • 头条网站开发外贸推广方式
  • 自己在百度上可以做网站吗seo技术
  • 二手网站模板360开户
  • 外贸公司手机网站发布外链的步骤
  • 一流的成都 网站建设关键词优化seo排名
  • 十堰做网站排名一站式自媒体服务平台
  • 上海网站seo百度手机网页版入口
  • 学服装设计学费要多少合肥seo网络优化公司
  • 如何建立一个学校网站360搜索推广官网
  • 网络服务工程师安全生产责任制最新版广州seo排名优化公司
  • 东莞市今天新增疫情seo软件定制
  • 如何用网站模板做网站简述网站推广的方式
  • 网站怎样获得利润近10天的时政新闻
  • 网站换肤代码宁波网站推广公司有哪些
  • 做网站用的笔记本配置竞价托管收费标准
  • 简约 个人网站老哥们给个关键词
  • 做任务游戏能赚钱的网站网站关键词收录查询
  • 网站设计 网站建设seo品牌优化整站优化
  • 医院网站建设情况说明优化大师班级优化大师
  • 做国际网站要多少钱网络营销策划方案ppt
  • 醴陵微信小程序网站开发价格百度推广获客成本大概多少
  • 广州网站建设 滚屏网络营销顾问工作内容