Mastering a variety of basic types is a prerequisite for proper processing of various data in programming, where data is stored and transmitted in bits (bit), and each 8 bits is composed of 1 bytes (byte). The word length of a 32-bit computer is 32, or 4 bytes, and the corresponding 64-bit computer has a word length of 64, or 8 bytes.
The bool has a length of 1 bytes, or 8 bits.
Char has a length of 1 bytes, while C + + is unique to a wchar_t of 2 bytes, or 16 bits.
int is usually 1 word length, short is half word length, long is 1 or 2 word length.
? Float is a length of one word, a double is two word lengths, and a long double is 3 or 4 word lengths.
The length of the memory that the pointer occupies is also determined by the system, which is 32 bits under the 32-bit system and 64 bits under the 64-bit system.
Run the following code according to Win32 conditions:
#include <iostream>using namespace Std;int main () {cout << "bool:" << sizeof (BOOL) << endl;cout &L t;< "char:" << sizeof (char) << endl;cout << "wchar_t:" << sizeof (wchar_t) << endl;cout &L t;< "short:" << sizeof (short) << endl;cout << "int:" << sizeof (int) << endl;cout << "Long:" << sizeof (long) << endl;cout << "float:" << sizeof (float) << endl;cout << "do Uble: "<< sizeof (double) << endl;cout <<" pointer: "<< sizeof (char*) << Endl;return 0;}
The result of the operation is as follows (sizeof returns the number of bytes):