Functions passed in structs, as args, and init'd

John/Consultant CWIKLA at uimrl7.mrl.uiuc.edu
Thu Feb 28 17:24:46 AEST 1991



	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 at uiucmrl, cwikla at uimrl7.mrl.uiuc.edu *
*  Chief Consultant, MRLCFC   *	  uimrl::cwikla		(217)333-8281        *
*  University of Illinois     *   Redefining Lunacy...			     *
******************************************************************************



More information about the Comp.lang.c mailing list