第六周-周记

 

这周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;

posted @ 2016-04-07 14:57  huangkaiyun  阅读(333)  评论(2编辑  收藏  举报