In C int* p and int** p as formal parameters

In C int* p and int** p as formal parameters

Suppose int *p = 0xfff0, &p = 0xffff
The address in the code may be different.
void fun1(int p)
corresponds to the calling function fun(p), the value of p is passed, and
the formal parameter type of 0xfff0 is pointer type int
, Among them, p is a formal parameter, which can be understood as the value 0xfff0 passed as p

The calling function corresponding to void fun2(int p) is fun (&p), the address of p is passed, and the formal parameter type of 0xffff is pointer type int

, where p is the formal parameter, which can be regarded as int *( p), among them It can be understood as the address of the value of P (0xfff0), which is 0xffff

#include <stdio.h>


void fun1(int *p)//接受的是p里面的值即为0xfff0
{
   
    
    

    printf("p = %p\n",p);
    p = 0x9999;
    printf

Guess you like

Origin blog.csdn.net/qq_44746568/article/details/109511467