How to pass the address of a pointer to a function in C

1 Answer

0 votes
#include <stdio.h>

void changeValue(int **p) {
    **p = 700;
}
    
int main()
{
    int n = 15;
    int *p = &n;
    
    printf("%d %d\n", *p, n);
    
    changeValue(&p);
    
    printf("%d %d\n", *p, n);
}



/*
run:

15 15
700 700

*/

 



answered Jun 19, 2024 by avibootz

Related questions

1 answer 108 views
1 answer 104 views
1 answer 155 views
1 answer 138 views
1 answer 155 views
1 answer 128 views
...