is f().c legal? How about (&(f()))->c ?
Wayne A. Throop
throopw at xyzzy.UUCP
Thu Feb 9 05:41:47 AEST 1989
> middleto at sdsu.UUCP (Tom Middleton)
>> Here f() returns a structure.
> I may be missing the point here but it seems that one problem is f()
> does not return a structure but rather a pointer to a structure.
Yes, indeed, you ARE missing the point. In particular you seem to be
confusing arrays and structures. In ansi C (which is what this
newsgroup is mostly about) structures can be passed by value and returned
as the result of a function. (In fact this has also been a common
extension to most C language systems based on K&R C for some time.)
> Seems to me that
> &(f()) is the address of the pointer returned by the function f and
> although (&(f()))-> is legal it isn't what you think it is.
Of course, the address-of operator "&" can only be applied to things
which "have addresses", and function results are not one of these.
--
I think. I think I am. Therefore I am ... I think.
--- Moody Blues
--
Wayne Throop <the-known-world>!mcnc!rti!xyzzy!throopw
More information about the Comp.std.c
mailing list