zoukankan      html  css  js  c++  java
  • 数据结构之typedef

    typedef

    typedef的用法
    #include <stdio.h>
    
    typedef int ZHANGSHAN;
    //为int再重新多取一个名字,ZHANGSHAN等价于int
     
    
    typedef struct Student
    {
        int sid;
        char name[100];
        char sex;
    }ST;
    
    
    int main(void)
    {
        /*
        int i = 10;//等价于ZHANGSHN i=10;
        ZHANGSHAN j = 20;
        printf("%d
    ",j);
        */ 
        struct Student st;//等价于ST st; 
        struct Student *ps = &st;//等价于ST *ps = &st; 
        return 0;
    } 
    #include <stdio.h>
    
    
    typedef struct Student
    {
        int sid;
        char name[100];
        char sex;
    }* PST;//PST等价于struct Student * 
    
    
    int main(void)
    { 
        struct Student st;
        PST ps = &st;
        ps->sid = 99;
        printf("%d
    ",ps->sid);
        
        return 0;
    } 
    #include <stdio.h>
    
    
    typedef struct Student
    {
        int sid;
        char name[100];
        char sex;
    }* PST,ST;
    //等价于ST代表了struct Student,PST代表了struct Student * 
    
    
    int main(void)
    { 
        STU st;//struct Student st;
        PSTU ps = &st;//struct Student *ps = &st;
        ps->sid = 99;
        printf("%d
    ",ps->sid);
        
        return 0;
    } 
  • 相关阅读:
    每日总结59
    每日总结58
    每日总结57
    每日总结56
    每日总结55
    每日总结54
    每日总结53
    每日总结52
    学习日报
    学习日报
  • 原文地址:https://www.cnblogs.com/pig1314/p/8652975.html
Copyright © 2011-2022 走看看