(CHAR *)(STRUCT)

John Mundt john at chinet.chi.il.us
Wed Nov 15 04:27:45 AEST 1989


In article <2401 at stl.stc.co.uk> dsr at stl.stc.co.uk () writes:
>I want to make up a macro which would take a pointer to anything and
>convert it into CHAR so that I could send the resulting string over a
>pipe...           However when I try it on Structures the compiler
>says that this is not allowed. 
>Is there any way around this?  Has anyone got a couple of routines to
>send any type data over a pipe from a generic call?


So, cast a pointer to the structure to char *, as in

	(char *) (&STRUCT)

and everyone will be happy.  Once you have the cast, you can send the
thing off with a read down a pipe, as in

	write(fd, (char *) &STRUCT, sizeof(STRUCT));

or wherever you want it to go.
-- 
---------------------
John Mundt   Teachers' Aide, Inc.  P.O. Box 1666  Highland Park, IL
john at admctr.chi.il.us *OR* fred at teacha.chi.il.us
(312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem  



More information about the Comp.lang.c mailing list