Your question:
Another thing, if I given a pointer as input to a specific function
(not main) and have done some manipulation with that pointer for instance I have changed the value of that pointer so after I finish from that function will the value gone? meaning will it be locally or the value still saved in that address? as we know in C programming if I defined a variable in a function its defined in the function itself and will gone once I get out from it ..
Answer:
Code:
#include <stdio.h>
int globalInt = 1;
void someFunc3(int **pt)
{
*pt = &globalInt;
}
void someFunc2(int *pt)
{
pt = &globalInt;
printf("Inside someFunc2, *pt=%d\n", *pt);
}
void someFunc1(int *pt)
{
*pt = 8;
}
void main()
{
int i;
int *iPtr;
iPtr = &i;
*iPtr = 5;
printf("Initial value of i=%d\n", i); // i = 5
someFunc1(iPtr);
printf("after call to someFunc1() i=%d\n", i); // Will show: i=8
someFunc2(iPtr);
printf("after call to someFunc2() *iPtr=%d .... iPtr keeps its value (which is &i)\n", *iPtr); // Will still show: *iPtr=8
someFunc3(&iPtr);
printf("after call to someOtherFunc() *iPtr=%d\n", *iPtr); // Will show: *iPtr=1
}