- or download this
int *mysub ();
main() {
...
z = 3;
return &z;
}
- or download this
$ make temp
gcc temp.c -o temp
temp.c: In function `mysub':
temp.c:13: warning: function returns address of local variable
- or download this
$ temp
in sub z = 0
in main x = 3
in sub z = 5
- or download this
use strict;
my $x;
...
return \$z;
}
- or download this
$ perl temp.pl
in sub $z = 0
in main $x = 3
in sub $z = 0
- or download this
int *mysub () {
static int z;
...