Returning value

What if we return the value of f as &f not as *f

Hello @bvidab18.

What if you will return char but the return type defined is int?

Now coming to your case:
suppose, f is a pointer pointing to some address say 0x123.
The value stored at that address is 23.

  • is known as de-referencing operator.
    So, when you return *f, you are returning the value stored at the address pointed by f i.e. 23 is returned.

But, & is ‘address of’ operator.
So, when you return &f, you are returning the address of the pointer f.
Note:
&f won’t return 0x123. This is not it’s address.

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.