9-7-2.c
来自「51单片机开发与应用技术详解(珍藏版)PPT及源码」· C语言 代码 · 共 22 行
C
22 行
#include <stdio.h> //头文件
struct student //定义结构
{
char *name; //姓名
int num; //学号
int age; //年龄
char *sex; //性别
float score; //分数
}boy[4]={ //初始化
{"Bob",101,24,"M",90.0},
{"Jack",102,25,"M",88.5},
{"Twis",103,23,"M",78.5},
{"Bohm",104,21,"M",82.5}};
void main() //主函数
{
struct student *pstu; //定义结构指针
printf("Name\tNum\tAge\tSex\tscore\n"); //输出
for(pstu=boy;pstu<boy+4;pstu++) //输出各元素的成员值
printf("%s\t%d\t%d\t%s\%f\n",(*pstu).name,(*pstu).num,pstu->age,pstu->sex,pstu->score);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?