Pass by Value vs. Pass by Pointer
void test(int val, int *ptr){ val = 1; *ptr = 1;}main() { int i1 = 0, i2 = 0; /* i1 is passed by value */ /* i2 is passed by pointer */ test( i1, &i2); /* i1 is unchanged, i2 was set to 1 */}
Previous slide
Next slide
Back to first slide
View graphic version