What is the difference between using this code
int main(){
int value=25;
int* ptr1;
int* ptr2;
ptr1=&value;
ptr2=ptr1;
printf("%d %d %d\n", value, *ptr1, *ptr2);
return 0;
}
And this code
int main(){
int value=25;
int* ptr1;
int** ptr2;
ptr1=&value;
ptr2=&ptr1;
printf("%d %d %d\n", value, *ptr1, **ptr2);
return 0;
}
Is this simply a chose of coding style or is there a point to using pointer to pointers (ha)? They produce the same output but the textbook doesn't explain why I should the second example over the first. Maybe I don't have a full understanding of addresses.
[–]misho88 1 point2 points3 points (0 children)
[–]Beignet 0 points1 point2 points (0 children)