C++ beginner(1)- C++ type

Size of C++ type

Integer


There is also a type called size_t which is either a 32-bit or 64-bit unsigned integer, depending on the CPU being compiled for.

four 8-bit types:

char type

The types named with char are due to their original usage for characters in ASCII strings. There are also larger character types:

floating-point type

choose which type to use

Given the uncertainty of size across CPU and OS, it’s a best practice to avoid many of these types and instead use types that have specific sizes.

Literals

0x, 0X: hexadecimal, e.g. 0x123456
': Digits of the chosen base. e.g. 0b10101010'01010101, 1'000'000
e: scientific notation, e.g. 1.123e5 == 112300
'c':char type if c fits, otherwise int type, with character c

char example:

posted @ 2022-08-16 19:34  FrancisForeverhappy  阅读(15)  评论(0编辑  收藏  举报