C/C++的数据类型sizeof长度以及基本类型取值范围

C/C++的数据类型sizeof长度以及基本类型取值范围

运行环境:

Linux asrock2 4.15.0-142-generic #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

#include
#include
#include

using namespace std;

int main(int argc, char **argv) {
        cout << "sizeof char:" << sizeof(char)<

【结论】

基本类型:

sizeof char:1
sizeof int:4
sizeof long:8
sizeof long long:8
sizeof long int:8
sizeof float:4
sizeof double:8
sizeof short:2

指针类型:

sizeof char p:8
sizeof int p:8
sizeof long p:8
sizeof long long p:8
sizeof long int p:8
sizeof float p:8
sizeof double p:8
sizeof short p:8

最大值:

max char:127
max unsigned int:255
max int:2147483647
max unsigned int:4294967295
max long:9223372036854775807
max unsigned long:18446744073709551615
max short:32767
max unsigned short:65535
max float:3.40282e+38
max double:1.79769e+308

最小值:

min char:-128
min unsigned int:0
min int:-2147483648
min unsigned int:0
min long:-9223372036854775808
min unsigned long:0
min short:-32768
min unsigned short:0
min float:1.17549e-38
min double:2.22507e-308

你可能感兴趣的:(basic,c++,开发语言,数据类型,c)