Date: Tue, 8 Mar 2005 11:34:55 +0100 From: Erik Trulsson <ertr1013@student.uu.se> To: Mark Jayson Alvarez <jay2xra@yahoo.com> Cc: freebsd-questions@freebsd.org Subject: Re: Is this a function or a structure???(once again, a mind-boggling example from Kernighan) Message-ID: <20050308103455.GA38972@falcon.midgard.homeip.net> In-Reply-To: <20050308102647.34788.qmail@web51605.mail.yahoo.com> References: <20050308102647.34788.qmail@web51605.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Mar 08, 2005 at 02:26:47AM -0800, Mark Jayson Alvarez wrote:
> Hi,
>
> On chapter 6 section 2 of The C Programming
> Language, the topic is Structures and Function.
>
> His very first example for this topic contains the
> lines of code:
>
> struct point makepoint(int x, int y)
> {
> struct point temp;
> temp.x = x;
> temp.y = y;
> return temp;
> }
>
> As I can understand it, he is trying to declare a
> structure of type "point", and the value of that
> structure will be the return value of the function
> "makepoint", or is it a function definition?
No, he is defining a function 'makepoint' that returns a value of type
'struct point'.
'struct point' is presumably defined at some earlier point.
(At a guess 'struct point' is defined as:
struct point
{
int x;
int y;
};
Such a definition would at least be reasonable, and consistent wwith
the usage of 'struct point' in the function 'makepoint')
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050308103455.GA38972>
