首页 > 其他 > 详细

typedef的用法

时间:2019-06-23 22:58:16      阅读:111      评论:0      收藏:0      [点我收藏+]

 typedef的用法

#include <stdio.h>

typedef int ZHANGSAN; //为int再重新多取一个名字,ZHANGSAN等价于int

typedef struct Student
{
   int sid;
   char name[100];
   char sex;
}ST; //为struct Student重新多取一个名字,叫ST

int main()
{
    //int i = 10;  //等价于 ZHANGSAN i = 10;
    //ZHANGSAN j = 20;
    ST st2;
    st2.sid = 200;
    printf("%d\n", st2.sid);
}

 

#include <stdio.h>

typedef int ZHANGSAN; //为int再重新多取一个名字,ZHANGSAN等价于int

typedef struct Student
{
   int sid;
   char name[100];
   char sex;
}* PST; //PST 等价于strut Student *

int main()
{
   struct Student st;
   PST ps = &st;
   ps->sid = 98;
   printf("%d\n", ps->sid);
}

 

#include <stdio.h>

typedef int ZHANGSAN; //为int再重新多取一个名字,ZHANGSAN等价于int

typedef struct Student
{
   int sid;
   char name[100];
   char sex;
}* PSTU, STU; //PSTU 等价于strut Student *, STU代表了struct Student

int main()
{
    STU st; //struct Student st;
    PSTU ps = &st; // struct Student * ps = &st;
    ps->sid = 99;
    printf("%d\n",ps->sid);
    return 0;
}

 

typedef struct Node
{
    int data; //数据域
    struct Node * pNext; //指针域;
}NODE, *PNODE; //NODE等价于 struct Node,  PNODE等价于struct Node *

 

typedef的用法

原文:https://www.cnblogs.com/spore/p/11074360.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!