Hello everyone,
here is a sample code where myptr is passed to myfuction. It is said that it will not work. to make it working we shud pass &myptr. I have confusion here that pointer contains the address of the variable.(here an int). so when i pass this i am passing the address to the called function. so why cant i modify in the called function. what will be the difference if i pass &myptr??????
Code:myfunction(int *ptr) { int myvar = 100; ptr = &myvar; } main() { int *myptr; myfunction(myptr); //Use pointer myptr. }