⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 9-7-1.c

📁 51单片机开发与应用技术详解(珍藏版)PPT及源码
💻 C
字号:
#include <stdio.h>							//头文件
struct student								//定义结构
{
char *name;								//姓名
int 	num;									//学号
int 	age;									//年龄
char *sex;									//性别
float score;								//分数
}Bob={"Bob",101,24," M ",90.0};				//声明并初始化结构变量

void main()								//主函数
{
struct student *pstu;							//定义结构指针
pstu=&Bob;								//为结构指针赋值
										//采用方式1输出成员值
printf("Name=%s,Num=%d\n",Bob.name,Bob.num);
printf("Age=%d,Sex=%s,score=%f\n",Bob.age,Bob.sex,Bob.score);
										//采用方式2输出成员值
printf("Name=%s,Num=%d\n",(*pstu).name,(*pstu).num);
printf("Age=%d,Sex=%s,score=%f\n",(*pstu).age,(*pstu).sex,(*pstu).score);
										//采用方式3输出成员值
printf("Name=%s,Num=%d\n",pstu->name,pstu->num);
printf("Age=%d,Sex=%s,score=%f\n",pstu->age,pstu->sex,pstu->score);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -