1.1 sizeof keyword
sizeof is a C language keyword, function is the size of the specified data type in memory, in bytes
sizeof and size_t types
1.1 int Type 1.1.1 int constant, variable
int is a 32-bit binary integer that occupies 4 bytes of space in memory
1.1.2 printf Output int Value
%d, output a signed 10 binary integer,%u, representing the output of an unsigned decimal integer
1.1.3 printf output octal and hex
%x, representing output 16 binary number,%x, uppercase output 16 binary number
%o represents output octal number
1.1.4 Short,long,long long,unsigned int
Short means a shorter integer, 2 bytes, 16 bits under a 32-bit system
Long is a longer integer, and under a 32-bit system, long is 4 bytes, and under 64-bit systems, Windows is 4 bytes, and Unix becomes 8 bytes.
int whether it's a 32-bit system or a 64-bit system, either Windows or UNIX is a 4-byte
A long long is a 64-bit, 8-byte integer, and for a 32-bit operating system, the CPU register is 32 bits, so it is inefficient to compute the longlong type of data.
9l,9l,9ll,9ll,9u,9ull,9ull
1.1.5 integer Overflow
When an integer is calculated that exceeds the maximum unit that the integer can hold, the integer overflows, and the result of the overflow is a high discard.
When a small integer is assigned to a large integer, the sign bit is not lost and will inherit
1.1.6 big-endian alignment and small end alignment
For a complex instruction CPU with this x86 architecture, integers are stored backwards in memory, low-arm,intel, high-address highs, and small-ended alignment.
But for UNIX server CPUs, it's more of a big-endian way to store integers.
#include <stdio.h>intMain () {intA =Ten;//4 byte size Shortb =Ten; printf ("%d\n",sizeof(b)); Longc =Ten; printf ("%d\n",sizeof(c)); Long LongD =Ten; printf ("%d\n",sizeof(d)); unsignedintE =Ten;//unsigned is a keyword that represents the meaning of an unsigned numberprintf"%d\n",sizeof(e)); //unsigned short F;// unsigned short//unsigned long g;//unsigned long//unsigned long long i;//unsigned long long//int i1;unsigned ShortABC =0xFFFF; ABC= ABC +1+ About; printf ("%d\n", ABC); ABC=2; ABC= ABC-5; printf ("%d\n", ABC); intI1 =0x12345678; ABC=I1; printf ("%x\n", ABC); ShortABC1 =-2; I1=ABC1; printf ("%x\n", I1); unsigned ShortABC2 =0; ABC2= ABC2-1; printf ("%d\n", ABC2); intA1 =0x12345678; printf ("%p\n", &A1);//%p means to display the address of a memory, &A1 represents the address number of the variable A1 return 0;}
Source: Intelligence Podcast for study only
Data types in 2_c languages (three) integers and unsigned numbers