数据结构之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;
} 
原文地址:https://www.cnblogs.com/pig1314/p/8652975.html