数据类型
整点类型 short int,int, long int, long long int浮点数类型 float, double, long double
基本类型—— 字符类型 char
指针类型 布尔类型 _Bool(只能表示真假俩种类型)
枚举类型 enum
数据类型
构造类型
空类型
sizeof运算符
sizeof运算符用于获取数据类型或表达式的长度
- sizeof(object);//sizeof(对象);
-sizeof(type_name);//sizeof(类型);
-sizeof object;//sizeof对象;
#include <stdio.h>
int main()
{
int i;
char j;
float k;
i=123;
j='c';
k=3.14;
printf("size of int is %d\n", sizeof(int));
printf("size of i is %d\n", sizeof(i));
printf("size of char is %d\n", sizeof(char) );
printf("size of j is %d\n", sizeof(j));
printf("size of float is %d\n", sizeof(float));
printf("size of k is %d\n", sizeof(k));
return 0;
}打印为 size of int is 4 size of i is 4 size of char is 1 size of j is 1 size of float is 4 size of k is 4 signed(前面带负号)和unsigned (前面不带负号)
signed short unsigned short signed intunsigned intsigned long unsigned long signed long long unsigned long long #include <stdio.h>
int main()
{
short i;
unsigned short j;
i = -1;
j = -1;
printf("%d\n", i);
printf("%d\n", j);
return 0;
}打印 -1 65535
页:
[1]