Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!uwm.edu!ux1.cso.uiuc.edu!usenet From: CWIKLA@uimrl7.mrl.uiuc.edu (John/Consultant) Newsgroups: comp.lang.c Subject: Functions passed in structs, as args, and init'd Message-ID: <1991Feb28.051449.25826@ux1.cso.uiuc.edu> Date: 28 Feb 91 06:24:46 GMT Sender: usenet@ux1.cso.uiuc.edu (News) Distribution: local,world,all Organization: University of Illinois, Materials Research Laboratory CFC Lines: 41 X-News-Reader: VMS NEWS 1.03 I have the following code pieces throughout a program: typedef struct _Astruct{ int (*myfunc)(); . . . } Astruct; int a_function(); then I do the following in a routine: . . . Astruct *AS; AS->myfunc = (int(*)())NULL; then later try to change it: AS->myfunc = a_function; But this doesn't work -- I get a segment dump...Am I doing this wrong??? (It segmentatoin faults at the last C line above.) Any hints or suggestion, or the err in my ways would be appreciated. ****************************************************************************** * John L. Cwikla * cwikla@uiucmrl, cwikla@uimrl7.mrl.uiuc.edu * * Chief Consultant, MRLCFC * uimrl::cwikla (217)333-8281 * * University of Illinois * Redefining Lunacy... * ******************************************************************************