Is this a function or a structure???(once again, a
mind-boggling example from Kernighan)
Erik Trulsson
ertr1013 at student.uu.se
Tue Mar 8 02:34:59 PST 2005
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 at student.uu.se
More information about the freebsd-questions
mailing list