🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5709

Re: is f().c legal? How about (&(f()))->c ?

#5709
From: Wayne A. Throop
Date: Wed, 08 Feb 1989 19:41
23 lines
1426 bytes
> middleto@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
Technical Details
Message-ID: <3322@xyzzy.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!ncsuvx!mcnc!rti!xyzzy!throopw
References: <2648@vedge.UUCP> <3459@sdsu.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!ncsuvx!mcnc!rti!xyzzy!throopw
From: throopw@xyzzy.UUCP (Wayne A. Throop)
Newsgroups: comp.std.c
Subject: Re: is f().c legal?  How about (&(f()))->c ?
Keywords: ansi
Message-ID: <3322@xyzzy.UUCP>
Date: 8 Feb 89 19:41:47 GMT
References: <2648@vedge.UUCP> <3459@sdsu.UUCP>
Organization: Data General, RTP NC.
Lines: 22