Sending struct through DGRAM socket
Mark William Hopkins
markh at csd4.csd.uwm.edu
Fri Apr 19 02:16:32 AEST 1991
In article <14918 at helios.TAMU.EDU> greg at carnivore.tamu.edu (Greg Economides) writes:
>Is there a quick/clean way to translate a struct into a character stream
>(and then a way to get the struct back) so that it can be sent using these
>functions?
Structs are formatted in a machine-dependent and compiler-dependent way. You
absolutely need to set up routines to break apart and form the struct by
hand. You know, like:
sprintf(Buf, "%5.3f:%5.3f:%5.3f\n", A->X, A->Y, A->Z);
SendBytes(Buf);
and whatever the corresponding sscanf and "RecvBytes" statements are.
More information about the Comp.lang.c
mailing list