hi all,
I just got this freaky kind of doubt....I have the following piece of code,
Technically speaking for the first function (TestFn) I am passing the address of the variable Val. So I can call this function as pass by reference function.
But when it comes to the second function (TestPtr), what i am doing is the following, the address of the Val variable is assigned to Ptr. So, for second function we are just sending the address directly as input parameter. You people get my point right, the function's input parameter is a pointer and the input is also a pointer (with the address of another variable). So this just an equivalent to pass by value (not with values, but with addresses in pointer variables)
Can I call this as pass by value then ?
Am I clear or do I need to be more descriptive....
I just got this freaky kind of doubt....I have the following piece of code,
Code:
int main() { int Val= 10, *ptr; ptr = &Val; TestFn(&Val); TestPtr(ptr); return 0; } void TestFn(int *i) { ....does some operations } void TestPtr(int *j) { ....does some other operations }
But when it comes to the second function (TestPtr), what i am doing is the following, the address of the Val variable is assigned to Ptr. So, for second function we are just sending the address directly as input parameter. You people get my point right, the function's input parameter is a pointer and the input is also a pointer (with the address of another variable). So this just an equivalent to pass by value (not with values, but with addresses in pointer variables)
Can I call this as pass by value then ?
Am I clear or do I need to be more descriptive....
Comment