Problem passing function argument as reference

There are function declarations and function invocation:

//function declaration
void func( int *val )
{
  val = 1;
}
...
int val;
//function invocation
func( &val );
// val is now = 1

The other way around, you are simply changing the value of a copy of "val" on the stack, which is lost once you exit the function.