From owner-freebsd-questions@FreeBSD.ORG Tue Mar 8 10:34:59 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D36BC16A4CE for ; Tue, 8 Mar 2005 10:34:59 +0000 (GMT) Received: from av9-2-sn4.m-sp.skanova.net (av9-2-sn4.m-sp.skanova.net [81.228.10.107]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0279A43D3F for ; Tue, 8 Mar 2005 10:34:59 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: by av9-2-sn4.m-sp.skanova.net (Postfix, from userid 502) id D732C37E6A; Tue, 8 Mar 2005 11:34:57 +0100 (CET) Received: from smtp4-1-sn4.m-sp.skanova.net (smtp4-1-sn4.m-sp.skanova.net [81.228.10.181]) by av9-2-sn4.m-sp.skanova.net (Postfix) with ESMTP id C776D37E42 for ; Tue, 8 Mar 2005 11:34:57 +0100 (CET) Received: from falcon.midgard.homeip.net (h201n1fls24o1048.bredband.comhem.se [212.181.162.201]) by smtp4-1-sn4.m-sp.skanova.net (Postfix) with SMTP id 93D2F37E48 for ; Tue, 8 Mar 2005 11:34:57 +0100 (CET) Received: (qmail 38981 invoked by uid 1001); 8 Mar 2005 10:34:55 -0000 Date: Tue, 8 Mar 2005 11:34:55 +0100 From: Erik Trulsson To: Mark Jayson Alvarez Message-ID: <20050308103455.GA38972@falcon.midgard.homeip.net> Mail-Followup-To: Mark Jayson Alvarez , freebsd-questions@freebsd.org References: <20050308102647.34788.qmail@web51605.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050308102647.34788.qmail@web51605.mail.yahoo.com> User-Agent: Mutt/1.5.6i cc: freebsd-questions@freebsd.org Subject: Re: Is this a function or a structure???(once again, a mind-boggling example from Kernighan) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Mar 2005 10:34:59 -0000 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') -- Erik Trulsson ertr1013@student.uu.se