数据类型本质
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a;
int b[10];
printf("sizeof(a) = %d, sizeof(b) = %d\n", sizeof(a), sizeof(b));
printf("b:%d, &b:%d\n", b, &b);
printf("b+1:%d, &b+1:%d\n", b+1, &b+1);
char************* p = NULL;
int* q = NULL;
printf("%d, %d", sizeof(p), sizeof(q));
printf("\n");
system("pause");
return 0;
}
利用typedef给类型起别名
#include <stdio.h>
#include <stdlib.h>
typedef unsigned int u32;
struct test {
int a;
int b;
};
typedef struct test2 {
u32 a;
u32 b;
}TEST;
int main(void)
{
struct test t;
TEST t2;
return 0;
}
void数据类型
- 如果函数没有返回值,必须用
void
修饰 - 如果函数没有参数,参数可以用
void
修饰int fun(void)
- 不能定义void类型的普通变量,
void a; //error,不能确定分配多大空间
void* p;//ok,根据系统就能确定分配空间大小