慢慢来,比较快
一、数据类型
二、C语言 有没有 字符串类型
答:没有字符串类型
三、每种 数据类型 的 大小 是多少?
#include<stdio.h>
int main()
{
printf("%d\n", sizeof(char));
printf("%d\n", sizeof(short));
printf("%d\n", sizeof(int));
printf("%d\n", sizeof(long));
printf("%d\n", sizeof(long long));
printf("%d\n", sizeof(float));
printf("%d\n", sizeof(double));
printf("%d\n", sizeof(long double));
return 0;
}
char | 1 |
short | 2 |
int | 4 |
long | 4 |
long long | 8 |
float | 4 |
double | 8 |
long double | 8 |
1. 为什么 int 和 long 的数据类型大小都是 4 字节?
C语言规定:sizeof(long) >= sizeof(int)
只要 long 的数据类型是比 int 大就可以了
2.字节有多大?
bit | 比特位 |
byte | 字节 |
1 byte | 8 bit |
KB | 1024 byte |
MB | 1024 KB |
GB | 1024 MB |
TB | 1024 GB |
PB | 1024 TB |
四、总结
存在这么多的类型,其实是为了更加丰富的表达生活中的各种值。