Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Length of output data type of C++ program
Length of output data type of C++ program
ANSI C/C++ basic data types:

Typesetting numerical range

Void with no value, 0 bytes.

Boolean value without range, 1 byte

True false signed short[int]/ signed short [int], 2 bytes.

-32768~32767 unsigned short integer [int], 2 bytes

0~65535 signed integer int /signed [int], 4 bytes.

-2147483648 ~ 2147483647 unsigned integer [int], 4 bytes.

0~4294967295 signed long integer [int]/ signed long integer [int], 4 bytes

-2147483648 ~ 2147483647 unsigned long [int], 4 bytes.

0~4294967295long long, 8 bytes

0 ~ 1 84467407370952000 signed character/signed character,1byte

-128~ 127 unsigned character, 1 byte

0~255 wide characters wchar_t (unsigned short integer. ), 2 bytes.

0~65535 single-precision floating-point floating-point number, 4 bytes

-3.4E-38~3.4E+38 double-precision floating-point double, 8 bytes

1.7e-308 ~1.7e+308 long double precision, 8 bytes.

Description:

(1) Signed and unsigned type modifiers are used to modify character types and shapes.

(2) Type modifiers short and long are used to modify character types and shapes.

(3) When using signed and unsigned, short and long to modify int shaping, int can be omitted.

(4) bool and wchar_t are unique to C++.

(5) In addition to the above table, C/C++ can also define enum, union union and struct structure types.

(6) The above sizeof has passed the Windows XP 32-bit platform test, and the number of bytes and numerical range of some types of data are determined by the operating system and the compilation platform. For example, on 16-bit computer, sizeof(int) = 2, while on 32-bit computer, sizeof (int) = 4; ; Sizeof(long) = 4 on a 32-bit computer, and sizeof(long) = 8 on a 64-bit computer. Also note that the pointer on the 64-bit machine accounts for 8 bytes.

(7)void literally means "untyped" and cannot be used to define variables. The real function of vanity lies in:

(8) The standard C++ library and STL also provide a general data structure: string class; Vector template vector; Deque template Deque; List of linked list class templates; Container adapter stack class stack (FIFO operation); Container adapter queue class queue (FIFO operation); Set the class set; Multiset-like multiset; Mapping category mapping; ; Multi-mapping class multimap;; Bit set; Iterators (pointer-like functions that access the contents of containers).

(9) In standard c++, the definition length of int depends on the word length of your machine, that is, if your machine is 32-bit, the length of int is 32-bit, if your machine is 64-bit, then the standard length of int is 64-bit, and __int64 in vc is an integer that realizes 64-bit length in 32-bit machine length.

(10) About int and long on 32-bit platform

Literally, long should be 64 bits, which is more reasonable. It's really a historical burden to treat long as 32 bits. New programming languages like C# treat long as 64 bits because there is no need to support old code.

Under the 32-bit platform, long is short, long(short) type is short for long(short) int type, and sizeof(long) = sizeof(int) = 4. Although the values of int and long are the same, the input and output formats are different. The format of printf int is %d, while the format of printf long is %ld.

Considering the portability of the program, it is still necessary to distinguish. However, when the required numerical range is 4 bytes, it is recommended to use int type, because there is only one type in the first edition of C language, and that is int.

(1 1) In Win32 API and MFC, in order to make the type name more semantic, a lot of typedef have been made for the above basic types. For example, BYTE, WORD, DWORD and dword in WINDEF. H