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

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - How can I merge Nodes & Webform Submissions into instances of one general Content Type in Drupal 6? -