Christian, 31 Jul Anthony Tibbs wrote to you:
AT> Try this:
AT> int *test (void);
AT>
AT> int main (void)
AT> {
AT> int *value;
AT>
AT> value = test;
test is a pointer to function returning an int pointer, not a pointer to an
int. Perhaps Anthony meant ``test()'' instead of ``test''.
AT> printf ("The value of \"value\" is: %d\n",value);
value is a pointer to an int, not an int as %d in the format string suggests.
AT> return 0;
AT> }
AT> int *test (void)
AT> {
AT> int *i = 5;
5 is an int, not a pointer to an int.
AT> return &i;
&i is a pointer to a pointer to an int, not a pointer to an int. Returning a
pointer to a local non-static variable is always bad. Well perhaps 'always'
is too strong: "Nothing is completely true, not even this", Multatuli ;-)
AT> }
AT>
AT> Since printf() uses quite a bit of stack space in its
AT> operations, you can be pretty sure that "value" will not be
AT> 5 when you check.
That's true. ;-)
To Anthony: you should really compile example code you post, preferrably with
all warnings turned on.
Bye,
Erik
---
---------------
* Origin: WarmelinkE@vertis.nl (2:282/1.60)
|