📄 ch22-7.c
字号:
#include"stdlib.h" /*程序中用到了函数malloc(),要用此嵌入语句*/
#include"stdio.h" /*程序中用到了函数printf(),要用此嵌入语句*/
#define NUM ok /*宏定义*/
struct stu /*定义一个结构体*/
{
int num;
char *name;
char sex;
float score;
};
void main()
{
struct stu *ps;
ps=(struct stu*)malloc(sizeof(struct stu)); /*开辟存储空间*/
ps->num=102; /*以下四行均为结构体成员初始化*/
ps->name="Zhang ping";
ps->sex='M';
ps->score=62.5;
#ifdef NUM /*条件编译*/
printf("Number=%d\nScore=%f\n",ps->num,ps->score);
#else
printf("Name=%s\nSex=%c\n",ps->name,ps->sex);
#endif
free(ps);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -