zoukankan      html  css  js  c++  java
  • 构造类型:数组枚举结构体

    构造类型:数组枚举结构体
    #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 ",s1.name,s1.gender,s1.number,s1.score);
    printf("%s ”,s1.name);
    //    printf("%s %c %d %.2f ",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 ",s1.name,s1.gender,s1.number,s1.score);
    //结构体嵌套
    //多个数据---利用数组
  • 相关阅读:
    高并发第八弹:J.U.C起航(java.util.concurrent)
    高并发第七弹:不可变对象及常用的工具类
    高并发第六弹:线程封闭(ThreadLocal)
    分布式爬取链家网二手房信息
    scrapy CrawlSpider爬取猎云网文章数据
    selenium实现12306网站自动抢票
    王者荣耀官方壁纸爬取
    使用 vsftpd 服务传输文件
    使用 Apache 服务部署静态网站
    iptables 与 firewalld 防火墙
  • 原文地址:https://www.cnblogs.com/sharkHZ/p/4984224.html
Copyright © 2011-2022 走看看