1. Memory Access: Direct access, indirect access.
Direct access: int a = 0; Assign a value directly to a. Choose a memory address and let him save 20 of this number.
A + = 10;
The A variable itself represents this memory unit, which represents that cell, four bytes. Access to memory units is achieved by assigning or taking values from the variable heap a.
Indirect access: data in memory is accessed through the number of memory units (addresses) and the number of bytes in the data . Using pointers for
(Computer memory calculation: 2G memory 0~2 31 square-1 bytes, each byte has 8 bits composed of 01);
2. Pointer: is the memory address. The memory address is simply a pointer.
&a refers to the address of a. printf ("%p", &a); The assigned address is assigned by the system. The printed &a is the address that the first byte occupies.
3. Pointer variable: The variable that stores the memory address
int a = 6;a is an integer variable;
If a 0x7fff5fbff86c,a is a pointer variable;
4. Defining pointer variables
int a = 10;
int *p = &a; (p is a variable, p is an address.) At this point * just play the role of the logo, tell the compiler p is a variable to store the address. Some people write this (int *) p = &a;
5. Use * To access the contents of the variable; printf ("%d", *p);p is an address, and P plus a * represents the value to be taken out of the address. How exactly to take? P represents the first address, and how many bytes are taken depends on the type when the pointer is defined. This is where the contents of the address are accessed indirectly using pointers. This is the time to read this memory content.
6. The * operator operates on the contents of P. *p = 40; At this time a = 40;
7. Pointer definition, assignment. int *p = NULL; A null constant equals 0, which is the first address of memory.
int a = 5;
p = &a; Assign value
8. Type of pointer
int *p = &a; integer pointer p refers to the first address of a, and then successive bytes of that type are taken.
9. int *: integer pointer accounts for 8 bytes (64-bit operating system), 4 bytes (32-bit operating system).
sizeof (P)
C Language---Primary pointers