usage of double pointers as arguments

后端 未结 4 2061
北海茫月
北海茫月 2021-01-13 22:33

Please find the code snippet as shown below:

#include  

int My_func(int **); 

int main() 
{ 
     int a =5;
     int *p = &a;
     My_Fu         


        
4条回答
  •  遥遥无期
    2021-01-13 23:34

    In short, in C when you pass something as a parameter, a copy will be passed to the function. Changing the copy doesn't affect the original value.

    However, if the value is a pointer, what it points to can be changed. In this case, if you want to affect the pointer, you need to pass a pointer to it down to the function.

提交回复
热议问题