pointers to functions

Alan Curtis apc at cbuxb.UUCP
Mon Jul 7 05:10:13 AEST 1986


>Secondly is it possible to have an array of type 'pointer to' function.
Ok, on my machine this works:

hi(a)	{
	return(2*a);
	}

by(a)	{
	return(4*a);
	}

int (*(func[2]))() = { hi, by };

main()
	{
	printf("0x%x, 0x%x, 0x%x, 0x%x.\n",
			func[0], func[1], (*func[0])(1), (*func[1])(1));
	}

To produce:

0x24, 0x30, 0x2, 0x4.

I assume this is what you where looking for??

Alan Curtis.



More information about the Comp.lang.c mailing list