I'm struggling to understand how does function return pointer, and the syntax on how it should be implemented. we can have function that return pointer
Please see below the attempt I've made so far :
here i am returning pointer which points to a local variable. suppose the variable x is stored at memory address at 2500 so the value of pointer will be 2500 and this value will be returning by function ()
Please see below the attempt I've made so far :
Code:
main ()
{
int *pointer;
pointer = function();
.....
}
int *function ()
{
int x = 5;
int *pointer = &x;
..........
return pointer;
}
here i am returning pointer which points to a local variable. suppose the variable x is stored at memory address at 2500 so the value of pointer will be 2500 and this value will be returning by function ()