c - Double pointers are also sometimes employed to pass pointers to functions by reference -


" double pointers employed pass pointers functions reference " can can explain me above statement, point function reference means ?

i believe example makes clearer :

//double pointer taken argument void allocate(int** p,  int n) {     //change value of *p, modification available outside function     *p = (int*)malloc(sizeof(int) * n); }  int main() {      int* p = null;      //pass address of pointer     allocate(&p,1);      //the pointer has been modified point proper memory location     //hence statement work     *p=10;      //free memory allocated     free(p);      return 0; } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -