首页 > 其他 > 详细

typedef in c

时间:2020-05-16 10:32:24      阅读:58      评论:0      收藏:0      [点我收藏+]

1.typedef: The typedef is used to give data type a new name. For example,

// After this line BYTE can be used 
// in place of unsigned char 
typedef unsigned char BYTE; 

int main() 
{ 
    BYTE b1, b2; 
    b1 = c; 
    printf("%c ", b1); 
    return 0; 
} 

2.How to use the typedef struct in C

Syntax

技术分享图片

 

 

 

Method one:

struct Point{
  int x;
  int y;
};
typedef struct Point Point;
int main() {
    Point p1;
    p1.x = 1;
    p1.y = 3;
    printf("%d \n", p1.x);
    printf("%d \n", p1.y);
    return 0;
}

Method two:

typedef struct Point{
  int x;
  int y;
} Point;
int main() {
    Point p1;
    p1.x = 1;
    p1.y = 3;
    printf("%d \n", p1.x);
    printf("%d \n", p1.y);
    return 0;
}

 

typedef in c

原文:https://www.cnblogs.com/JasperZhao/p/12898177.html

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