p7 struct and union
2016-01-04 11:52
176 查看
struct StudentRec //①声明结构体类型StudentRec
{
char StuNum[20]; //②定义结构体的成员变量
char StuName[20]; //② 1.Dot “.” is called the member selection operator.
2. After the struct type declaration, the various members can
be used in your program only when they are preceded by a struct variable name and a dot.
int Score1; //②
int Score2; //②
int Admit; //②
} ;
//用结构体类型定义变量stu1和stu2
struct StudentRec stu1, stu2;
//访问结构体变量stu1中的成员
strcpy(stu1.StuNum, "0001");
strcpy(stu1.StuName, "Zhangsan");
stu1.Score1 = 90;
stu1.Score2 = 100;
stu1.Admit = 1;
printf( "%s %s %d %d %d\n",
stu1.StuNum, stu1.StuName,
stu1.Score1, stu1.Score2, stu1.Admit );
struct studentRec* pStu;
strcpy( pStu->num, “1000” );
strcpy( pStu->num, “Linda”;
pStu->Sccore1 =89;
{
char StuNum[20]; //②定义结构体的成员变量
char StuName[20]; //② 1.Dot “.” is called the member selection operator.
2. After the struct type declaration, the various members can
be used in your program only when they are preceded by a struct variable name and a dot.
int Score1; //②
int Score2; //②
int Admit; //②
} ;
//用结构体类型定义变量stu1和stu2
struct StudentRec stu1, stu2;
//访问结构体变量stu1中的成员
strcpy(stu1.StuNum, "0001");
strcpy(stu1.StuName, "Zhangsan");
stu1.Score1 = 90;
stu1.Score2 = 100;
stu1.Admit = 1;
printf( "%s %s %d %d %d\n",
stu1.StuNum, stu1.StuName,
stu1.Score1, stu1.Score2, stu1.Admit );
struct studentRec* pStu;
strcpy( pStu->num, “1000” );
strcpy( pStu->num, “Linda”;
pStu->Sccore1 =89;
相关文章推荐
- java.lang.VerifyError解决方案
- Android编程使用内容提供者方式(ContentProvider)进行存储的方法
- 计算几何的相关知识
- hdu2553 N皇后问题【二进制状态压缩基础】
- 标签TextView
- 世界摄影大赛获奖精品!令人惊叹!
- Meteor 拦截回车键 回车搜索 及其他键盘事件
- Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'
- 人工生命
- UITabBarController使用
- MySql ERROR 1205:Lock wait timeout exceeded; try restarting transaction
- shell date cal
- PHP数据库连接mysql与mysqli对比分析
- intellij idea导出jar包
- Android 类似未读短信图标显示数字效果的分析
- 欢迎使用CSDN-markdown编辑器
- Apache的Directory配置指南
- linux使用iscsi磁盘的几个步骤
- Android 5.0最应该实现的8个期望
- 非阻塞通道