美文网首页
12.20学习总结

12.20学习总结

作者: Tangjiayue92 | 来源:发表于2016-12-21 11:45 被阅读0次

昨天生病提前回去了,所以部分内容没有听到,会在这两天尽快赶上。
函数定义
不能嵌套定义
函数名不能与系统函数重名
函数的返回值
函数指针
指针函数

==========================================================

复杂数据类型
结构体
联合体
枚举类型

1.结构体
基本定义
struct 结构名
{
//成员列表
};
成员列表:
有基本数据类型定义的变量或者是构造类型的变量
example
struct student
{
int grade;
int age;
char name[32];
};
student:结构体名称
struct student:数据结构类型,相当于int,double,char等基本数据类型;
struct student stu;
stu:结构体变量
访问结构成员:“.”
访问结构体成员:
stu.name;
stu.grade;
stu.age;

结构体变量的初始化
struct student
{
char name[32];
char sex;
int age;
};

 初始化1
 struct student boy;
 strcpy(boy.name,"jack");
 boy.sex='m';
 boy.age=24;

 初始化2
 struct student girl={‘lily’,‘f’,23};

 初始化3

无名结构体
struct
{
int age;
char name[16];
}stu;
无名结构体一般不使用

宏定义结构体
宏是原地替换
struct student
{
char name[32];
char sex;
char age;
};

define STU struct student

结构体的嵌套
struct birthday date
{
int year;
int month;
int day;
};
struct student
{
char name[32];
int age;
struct birthday date;
};

int main()
{
struct student stu;
strcpy(stu.name,"hello");
stu.age=31;
stu.birthday.year=1900;
stu.birthday.month=5;
stu.birthday.day=6;
printf("%s,%d,%d,%d,%d\n",stu.name,stu.age,stu.birthday.year,stu.birthday.month,stu.birthday.day);
}

结构体指针
{
结构体
};
struct datepa;
struct student
pb;

include<stdlib.h>

malloc(); //申请空间
free(); //释放空间
//申请一块堆空间,大小为:sizeof(struct student)
pa=(struct date*)malloc(sizeof(struct date));
free(pa);

typedef
重新取名
typedef int I;
即给int取了别名I;
结构体

结构体的大小
内存对齐:
linux:4字节
windows:8字节
默认从偏移量为0的位置开始储存
int 从第四个开始存
long 从第八个开始存

联合体
union untype
{
int a;
long b;
};
特点
最多只能操作一个成员变量
分配空间按最大数据类型分配

枚举类型
enum entype
{
A,
B,
C=12
D,
E
};

int main()
{
printf("A=%d\n",A);
printf("b=%d\n",B);
:
:
:
输出为 0,1,12,13,14

switch case
case要记得和break配套使用

enum type
{
A,
B,
C
};

int main()
{

}

12.链表

 链式存储结构,线性储存结构

(1)创建链表
struct student
{
int id;
struct student *head;
};

     struct student *head;
     malloc()
     free()
     创建一个头节点:
     struct student *head;
    head=(struct student *)malloc(sizeof(struct student));
    头结点标识一个链表,即链表名称

相关文章

  • 12.20学习总结

    昨天生病提前回去了,所以部分内容没有听到,会在这两天尽快赶上。函数定义不能嵌套定义函数名不能与系统函数重名函数的返...

  • 12.20每日总结

    今天上午我请假了。问了同学说讲了显示屏的显示和万年历,看了老师的给的程序,还行。下午老师讲的是串口的接收。加上昨天...

  • 12.20小总结

    工作列表: 1.完成12.21日的公告文案核对 10min 2.音频课转文字稿一篇,12.21的思路分...

  • 直播总结12.20

    直播总结 1.直播期间主播和副播要穿能卖的衣服。 2.直播前一天,货品要对接好库存。和确定好发货的时间。 3.边讲...

  • 直播总结12.20

    直播总结 1.直播期间主播和副播要穿能卖的衣服。 2.直播前一天,货品要对接好库存。和确定好发货的时间。 3.边讲...

  • 见证历史的时刻,升水,贴水,美原油(WTI)05,美原油(WTI

    美原油05=12.20美元。 美原油06=22.19美元 升水(12.20-22.19)/12.20=81.82%...

  • 12.20学习笔记

    继续搞一搞ug制图,今天听了老师讲述了大多数技能,下午熟悉了这些技能,可以基本操作啦,下午和晚上回去又继续...

  • 学习打卡12.20

    昨天主要做了文言文 多做题还是有好处的 把很多疏漏的点搞明白了

  • 12.20 365系统总结

    365系统也叫365寻鹰行动,365系统裂变是招代理,寻鹰是寻找人才 365系统分为三个阶段 ...

  • 晚思总结 12.20

    今天我学到了什么? 演讲中的手势,人的第二语言。 容易出现的错误;做小动作、10cm的范围、不要做频繁的动作、不稳...

网友评论

      本文标题:12.20学习总结

      本文链接:https://www.haomeiwen.com/subject/nauxvttx.html