Any data type we can think of as a mold, and then into various types of data;
Any mold is of its particular size.
int *p;
With sizeof test, sizeof (p) or sizeof (int) is 4byte, so it can be defined as:
A mold of type int carves a space of 4 bytes in memory and then names the 4 byte size space as P. Also limit the 4 bytes of contiguous space can only store a memory address, even if you deposit any other data, will be treated as an address, and the memory address of the beginning of a continuous 4 bytes can only store an int data.
We refer to p as the pointer variable, and memory at the memory address stored in P is called P-pointing memory.
int *p = null and *p = NULL
The first one is initialization. What is the initial, that is, the address of P itself is initially 0.
*p = null is the initial content of P pointing to 0.
Double *p = NULL;
printf ("%d\n", sizeof (p)); is always 4byte, the space of the pointer variable itself
int *pt = NULL;
printf ("%ox\n", PT); View PT value As ox through the compiler
int i = 10;
int *pp = &i;
printf ("%d\n", I);
*PP = NULL;
printf ("%d", I); The value of the last I becomes 0
Look again:
int *p;
*p = NULL;
A pointer variable p is defined, but the address of P itself is not known, perhaps it is illegal, the role of subsequent may also be error.
Improved:
int i = 20;
int *p = &i;
*p = NULL;
Stores a value to the specified memory address:
Assuming that the value 0x100 stored on the address of 0x12ff7c, then this address can be obtained: I can arbitrarily define a variable, such as int i, and then take the address, then this address must be accessible.
int *p = (int *) 0x12ff7c;
*p = 0x100;
You can also do this: * ((int *) 0x12ff7c) = 0x100;
This article is from the "Genius Strength" blog, please be sure to keep this source http://8299474.blog.51cto.com/8289474/1583540
C Pointer base