c change pointer inside function code example
Example 1: c programm pointer change in function
void change(int **p, int *someOtherAddress) // **p *b allazei o p kai deixnei sto b //
{
*p = someOtherAddress;
}
int a = 1, b = 2;
int *p = &a;
printf("*p = %d\n", *p);
change(&p, &b);
printf("*p = %d\n", *p);
Example 2: c programm pointer change in function
int* change_adrs(int *q) //me return kai anathesh: p=returned kai synarthsh me mesa *kati=&x x=5;//
{ //xwris reference, by value.Epistrefei apla dieythynsh kathorismenh sthn synarthsh panta to 875002//
int * otheraddess;
q = otheraddress;
return q;
}
int main()
{
p=change_adrs(p);
return 0;
}