Pointers as Function Parameters¶
Call by Reference (1)¶
|
void f(int a)
{
a = 42;
}
void main(void)
{
int i = 1;
f(i);
/* i is still 1 */
}
|
Call by Reference (2)¶
Solution: pointer
void f(int *a)
{
*a = 42;
}
void main(void)
{
int i = 1;
f(&i);
}