typedef //定义类型
typedef unsigned long long uint64;//定义类型,起外号
例如:typedef struct student
{
int num;
char name[10];
int age;
}student;
注意:typedef int (*pfun)(int,int)//函数指针(指向函数的指针)
typedef int* pint;
#define PINT int *
int main()
{
pint a,b;
PINT c,d;
问a,b,c,d的类型?
答案:a,b,c都是指针类型,d是整数类型。因为c是宏定义。
}
//c语言规定,函数名也表示函数的入口地址
//结构体的大小
struct A
//让所有的成员放在能够被其整除的位置上
{
char a;//1
int b;//4
}8//向后对齐
struct D
{
char a;//1+3
int c;//4
short b;//2
}10+2
注意!!!这里是12,不是10,因为这个数必须是最大字节(也就是int)4的倍数
有时候会多定义一个 char d;//占位作用
不用的定义在里面,解决对其问题
struct A
{
int a;
struct EE
{int b;
char c;
}d;//8
}//12(单个)和int对齐