Skip to content

typedef

概念

C语言允许为类型定义一个新名称

意义:

  • 可以让类型的名字更短,提高开发效率
  • 便于区分系统位数

使用

c

#include <stdio.h>
typedef struct Person
{
    int age;
} Person;

int main ()
{
    Person person;
    person.age = 8;
    printf("%d\n",person.age);
 
    
    typedef char C;
    
    C c = 'a';
    
    printf("%c\n",c);
    
    return 0;
}