Hi all,
I'm trying to understand how pointers for function parameters work. As I
understand it, if you got a function like:
void f(int *i)
{
*i = 0;
}
int main()
{
int a;
f(&a);
return 0;
}
It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand, the address of "a" is
passed, and "*i" is set with this address not "i", as it should be in my
understanding.
What am I missing?
TIA
P.S.
I've really searched for this in the groups faq and elsewhere before I
posted.
I'm trying to understand how pointers for function parameters work. As I
understand it, if you got a function like:
void f(int *i)
{
*i = 0;
}
int main()
{
int a;
f(&a);
return 0;
}
It does what you want (namely altering the value of a).
I find this illogical. As far as I can understand, the address of "a" is
passed, and "*i" is set with this address not "i", as it should be in my
understanding.
What am I missing?
TIA
P.S.
I've really searched for this in the groups faq and elsewhere before I
posted.
Comment