[Study Notes] [C Language] memory Analysis of variables, learning notes C language Variables
1. bytes and address
To better understand the storage details of variables in the memory, first let's take a look at the "Byte" and "Address" in the memory ".
1> memory in bytes"
The above statement is not recommended.
3. course code
1 # include <stdio. h> 2 3 4 // 1. memory addressing ranges from large to small, and the bytes with a large memory address are preferentially allocated to variable 5 6 // 2. the more defined the variable, the larger the memory address is. get the address of the variable: & variable name 9 10 // 4. output address: % p 11 12 // 5. a variable must be initialized before it can use 13 14 15 int main () 16 {17 // memory addressing from large to small 18 int a = 10; 19 20 int B = 20; 21 22 int c; 23 24 // & is an address operator. The obtained variable address 25 // % p is used to output the address 26 // 0x7fff56f09bc8 27 printf ("the address of a is: % p \ n ", & a); 28 // 0x7fff56f09bc4 29 printf (" B address: % p \ n ", & B ); 30 // 0x7fff56f09bc0 31 printf ("c Address: % p \ n", & c); 32 33 // Since variable c has not been initialized, so it is wrong to use it directly. 34 // int d = c + 1; 35 36 37 printf ("the value of c is % d \ n", c ); 38 39 return 0; 40 41}