构造类型:数组\枚举\结构体
#import <Foundation/Foundation.h>
//结构体:构造类型,是一种自定义类型.
//struct CPoint//struct 是关键字用来声明结构体 后面是结构体的名字 花括号里面的内容叫成员变量
//{
//    float x;
//    float y;
//   
//};// 以分号结尾
typedef struct car{
////    char name[20];
////    int number;
////    float score;
////}Ca;
//struct//匿名结构体 没有名字 结构声明和结构体变量放在一起,不常用
//{
//    char name[20];
//    char happy[20];
//}l1 = {"yuanxinfeng","nv"};
////typedef 第一种 typedef 可以很好地简化结构体名 所以以后声明结构体推荐使用typedef第二种
////typedef struct student Stu;
//
////typedef 第二种

//typedef struct person{char name[20];
//    char gender;
//    int number;
//    float score;
//}Per;
////结构体内存占用规则:   1一内存占用最大的成员变量类型为单位    2自上而下的进行分类
struct student{
    char name[10];
    int score;
    int age;
    float x;
    char y;
    double z;
};//40
//访问成员变量 使用.进行访问 用结构体变量名.成员变量名
//    printf("%s %c %d %.2f\n",s1.name,s1.gender,s1.number,s1.score);
printf("%s\n”,s1.name);
//    printf("%s %c %d %.2f\n",s1.name,s1.gender,s1.number,s1.score);
//    s1.score = 98;
//    s1.gender = 'm';
//    s1.number = 10;
//    strcpy(s1.name, "yuanxinfeng");//字符串数组不可以直接赋值,运用函数赋值
//    s1 = s2;//结构体变量可以直接赋值
//    printf("%s %c %d %.2f\n",s1.name,s1.gender,s1.number,s1.score);
//结构体嵌套
//多个数据---利用数组
posted on 2015-11-21 17:27  sharkHZ  阅读(181)  评论(0编辑  收藏  举报