第六周-周记

 

这周C语言学习了单个结构体、结构体嵌套以及结构体中嵌套结构指针,单个结构可以掌握,结构体嵌套也会一些,结构体中嵌套结构指针完全不会。

HTML5学习了如何制作一个小游戏,我觉得挺有趣的。中专学的是以设计的的形式制作页面,而现在却是以编代码的形式制作页面,个人觉得用设计的会简单一些。

以下是一段代码,虽然没有每条都理解。

 

#include "stdafx.h"
#include "stdlib.h"
#include "string.h"
struct date
{
int year;
int month;
};
struct stu1
{
int num;
struct date birth;
};
typedef struct stu2
{
int num;
struct date *pbirth;
}student;
int main(int argc, char* argv[])
{
struct date d,*pd;
d.year=1997;
d.month=1;

printf("变量输出 %d年%d月\n",d.year,d.month);
pd=(struct date *)malloc(sizeof(struct date));
pd->year=2000;
pd->month=12;
printf("变量输出 %d年%d月\n",pd->year,pd->month);

struct stu1 st,*pst;
st.num=315710229;
st.birth.year=1997;
st.birth.month=1;
printf("变量输出 学号=%d 出生日期:%d年%d月\n",st.num,st.birth.year,st.birth.month);
pst=(struct stu1 *)malloc(sizeof(struct stu1));
pst->num=2341;
pst->birth.year=2012;
pst->birth.month=2;
printf("变量输出 学号=%d 出生日期:%d年%d月\n",pst->num,pst->birth.year,pst->birth.month);
student stu,*pstu;
stu.num=315710229;
stu.pbirth=(struct date *)malloc(sizeof(struct date));
stu.pbirth->year=1997;
stu.pbirth->month=1;
printf("变量输出 学号=%d 出生日期:%d年%d月\n",stu.num,stu.pbirth->year,stu.pbirth->month);
pstu=(student *)malloc(sizeof(student));
pstu->pbirth=(struct date *)malloc(sizeof(struct date));
pstu->num=2341;
pstu->pbirth->year=2012;
pstu->pbirth->month=2;
printf("变量输出 学号=%d 出生日期:%d年%d月\n",pstu->num,pstu->pbirth->year,pstu->pbirth->month);

return 0;

转载于:https://www.cnblogs.com/hky0206/p/5363625.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值