Path: utzoo!censor!geac!jtsv16!uunet!aplcen!samsung!usc!cs.utexas.edu!rutgers!att!chinet!john From: john@chinet.chi.il.us (John Mundt) Newsgroups: comp.lang.c Subject: Re: (CHAR *)(STRUCT) Message-ID: <1989Nov14.172745.16194@chinet.chi.il.us> Date: 14 Nov 89 17:27:45 GMT References: <2401@stl.stc.co.uk> Reply-To: john@admctr.chi.il.us (John Mundt) Organization: Chinet - Chicago Public Access UNIX Lines: 24 In article <2401@stl.stc.co.uk> dsr@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@admctr.chi.il.us *OR* fred@teacha.chi.il.us (312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem