关键字 typedef 可以为类型起一个新的别名,但typedef 对C语言已有的数据类型(int、float、char...)另命名时,只是赋予现有类型一个新的名字,而不是创建新的类型,因此程序允许新名旧名同时定义变量。
#includetypedef char cbyte; typedef int ibyte; typedef float fbyte; typedef double dbyte; int main() { cbyte c1 = 'A'; ibyte i1 = 1; fbyte f1 = 3.14f; dbyte d1 = 4.15; char c2 = 'B'; int i2 = 2; float f2 = 3.15f; double d2 = 4.16; printf("%cn", c1); printf("%dn", i1); printf("%fn", f1); printf("%lfnn", d1); printf("%cn", c2); printf("%dn", i2); printf("%fn", f2); printf("%lfn", d2); return 0; }
输出为:



