Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - On "Pointer" in TurboC
On "Pointer" in TurboC
Integer and address are 4 bytes, so integer and address can be converted to each other. You can treat an integer as an address or an address as an integer, which is the flexibility of C language, but you must be careful when using it to avoid serious memory problems.

For example:

int a;

int * p 1;

int * * p2

You can use it like this:

p 1 = & amp; a; //p 1 points to the address of a.

You can also use it like this:

p 1 =(int *)p2;

Then, when accessing **p2, you can do this:

int * P3 =(int *)(* p 1); //that is, *p 1 as an address instead of an ordinary integer.

*p3 is the value in **p2;

The above is just a concept, and the specific application depends on your application.

Supplement: = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

As mentioned earlier, for example:

int * p 1;

int * p2

p 1 =(int *)& amp; p2; //p 1 Point to the address of p2.

To access *p2, you can:

int * P3 =(int *)(* p 1); //Because *p 1 is an integer, it is necessary to convert the integer into an integer pointer, that is, the address pointed by p2 is saved in *p 1.

The value of *p3 is the value of *p2.