Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What does int *p=NULL mean in C language?
What does int *p=NULL mean in C language?

int *p=NULL in C language means:

P in C language is a random value, and in int *p=NULL, this P is valuable and null;

int *p=NULL points to an empty pointer, which is equal to int * p = ; NULL equals ;

you can always point this p to another address. Defining a pointer and initializing it to NULL is more standard programming.

the function of extended data *p = NULL

means to assign a value of to a variable pointed by pointer p (I don't know what type), which means to assign that variable to .

int *p;

*p = NULL;

the first line of code defines a pointer variable p, and the memory it points to stores data of type int; But at this time, the value of the variable p itself is unknown, which means that the variable p may now hold an illegal address.

the second line of code assigns NULL to *p, that is, assigns null to the memory pointed by p; However, because the memory pointed by P may be illegal, the compiler may report a memory access error when debugging. In this case, you can rewrite the above code to make p point to a legal memory:

int i = 1;

int *p = & i;

*p = NULL;