Download presentation
Presentation is loading. Please wait.
1
Example 1 125 100 100 passing the address of x x pint or
int x = 100; sub1 (&x); void sub1 (int *pint) { *pint = *pint + 25; } passing the address of x x pint or de-referenced value of pint is the value of what pint points to pint &x
2
Example 2 125 passing the value of p which is the address of x 100 100
int x = 100; int *p = &x; sub1 (p); void sub1 (int *pint) { *pint = *pint + 25; } x pint p de-referenced value of pint is the value of what pint points to
3
Example 3 125 passing the address of p 100 100 x p ppint
int x = 100; int *p = &x; sub2 (&p); void sub2 (int **ppint) { **ppint = **ppint + 25; } x p ppint double de-referenced value of ppint is the value of the value of what ppint points to
4
Example 4 100 x passing the address of p p ppint
int x = 100; int *p = &x; sub2 (&p); void sub2 (int **ppint) { *ppint = malloc(sizeof(int)); **ppint = 50; } x passing the address of p p ppint single de-referenced value of ppint is the value of what ppint points to. In this case, we are assigning a value to what ppint points to. 50 double de-referenced value of ppint is the value of the value of what ppint points to malloc-ed
5
Example 5 100 x passing the address of p p ppint
int x = 100; int *p = &x; sub2 (&p); void sub2 (int **ppint) { ppint = malloc(sizeof(int)); *ppint = 50; } x passing the address of p p ppint no de-referencing !! What is this changing? 50 single de-referenced value of ppint is the value of what ppint points to ppint itself malloc-ed
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.