c - Why use & to pass value for function with *? -


i wanted ask author, caf , understanding functions , pointers in c

i realized can't ask question on same page.

i'm still confused using & pass value of pointer function. thought &q passing address of q, how going translate value of q int sqp(int * x)?

there no "translation".

your function

int sqp(int *x); 

takes 1 argument, x, type int *, i.e. "pointer integer".

so, call need pass pointer integer, i.e. address of integer.

the & prefix operator used compute address of argument, can do:

int foo = 4711; sqp(&foo); 

to call sqp() function address of variable foo.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -