数据结构_P12

# include <stdio.h>
/*
*	链表预备知识: typedef给数据类型(int、char、struct Student...)再取一个名字,两个都能用
*	2016年6月9日13:35:54	
*/

typedef struct Student stt2; //struct Student数据类型再定义一个新名字:stt; 注: Student不是一个类型,struct Student才是一个数据类型

typedef struct Student
{
	int sid;
	char name[100];
	char sex;
} stt3;               //也可以这样写

int main(void)
{
	struct Student st;
	st.sid = 100;
	printf("%d\n", st.sid);

	stt2 st2;
	st2.sid = 30;
	printf("%d\n", st2.sid);

	stt3 st3;
	st3.sid = 20;
	printf("%d\n", st3.sid);

	return 0;
}


P12_2:

# include <stdio.h>
/*
*	链表预备知识: typedef给数据类型(int、char、struct Student...)再取一个名字,两个都能用
*	2016年6月9日14:28:14	
*/

typedef struct Student
{
	int sid;
	char name[100];
	char sex;
}* PST;			//这样写PST就代表struct Student* 类型,指针

int main(void)
{
	struct Student st;
	st.sid = 100;
	printf("%d\n", st.sid);

	PST pst = &st;
	pst->sid = 99;
	printf("%d\n", pst->sid);

	return 0;
}

P12_3:

# include <stdio.h>
/*
*	链表预备知识: typedef给数据类型(int、char、struct Student...)再取一个名字,两个都能用
*	2016年6月9日14:47:45	
*/

typedef struct Student
{
	int sid;
	char name[100];
	char sex;
} STU, *PSTU;			//这样写PSTU就代表struct Student* 类型指针,STU代表struct Student类型。两个一起连着写更方便!

int main(void)
{
	struct Student st;
	st.sid = 100;
	printf("%d\n", st.sid);

	STU st2;
	st2.sid = 90;
	printf("%d\n", st2.sid);

	PSTU pst = &st2;
	pst->sid = 99;
	printf("%d\n", pst->sid);

	return 0;
}



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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值