c语言的typedef
一、typedef作用简介 1.作用:给已经存在的类型起一个新的名称 2.使用场合: 1> 基本数据类型 2> 指针 3> 结构体 4> 枚举 5> 指向函数的指针 * 我们可以使用typedef关键字为各种数据类型定义一个新名字(别名)。 1 #include <stdio.h> 2 3 typedef int MyInt; 4 typedef MyInt MyInt2; 5 int main() 6 { 7 // 定义结构体变量 8 int a; 9 MyInt i = 10; 10 MyInt2 c = 20; 11 12 13 printf("i is %d\n", i); 14 printf("c is %d\n", c); 15 16 return 0; 17 } 1 #include <stdio.h> 2 3 typedef int Integer; 4 typedef unsigned int UInterger; 5 6 typedef float Float; 7 8 int main(int argc, const char * argv[]) { 9 Integer i = -10; 10 UInterger ui = 11; 11 12 Float f = 12.39f; 13 14 printf("%d %d %.2f", i, ui, f); 15