C question (memory allocation and access)

Peter da Silva peter at ficc.uu.net
Fri Nov 17 04:56:42 AEST 1989


How about this:

union padding {
	int mn[2];
	double d;
};

	block = malloc(sizeof (union padding) + whatever * sizeof (double));

	((int *)block)[0] = m;
	((int *)block)[1] = n;
	start_of_double_array = &((union padding *)block)[1];
-- 
`-_-' Peter da Silva <peter at ficc.uu.net> <peter at sugar.hackercorp.com>.
 'U`  --------------  +1 713 274 5180.
"vi is bad because it didn't work after I put jelly in my keyboard."
   -- Jeffrey W Percival (jwp at larry.sal.wisc.edu)



More information about the Comp.std.c mailing list