Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Jul 2005 18:36:09 +0200
From:      "Juan J." =?ISO-8859-1?Q?Mart=EDnez?= <reidrac@usebox.net>
To:        Matt <mhersant@comcast.net>
Cc:        freebsd-hackers@FreeBSD.ORG, misc@openbsd.org
Subject:   Re: C programming question
Message-ID:  <1120667769.8695.10.camel@localhost.localdomain>
In-Reply-To: <42518AC9.5070208@comcast.net>
References:  <42518AC9.5070208@comcast.net>

next in thread | previous in thread | raw e-mail | index | archive | help
El lun, 04-04-2005 a las 11:43 -0700, Matt escribió:
> [...]
> Can someone break down these declarations (if that's what they are)?  Is 
> this a form of typecasting?  Thanks for your help.

Those are declarations of pointers to functions.

/* real function */
void dumb(int a) { return a; }
...

/* here follows a declaration of func pointer */
int (*func_ptr)(int);
int a;

/* assign it */
func_ptr=dumb;

/* use it */
a=func_ptr(123);

Any good book about C should cover this. Look for OOP in C also, it's
frequent use pointers to functions + structs to add classes to C.

regards,

Juanjo

-- 
Desarrollo y sistemas: http://www.usebox.net/
      Página Personal: http://www.usebox.net/jjm/






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1120667769.8695.10.camel>