Looking for memcpy() and memcmp() routines in C

Michael Paul Hunter bagpiper at oxy.edu
Sun Feb 26 06:43:04 AEST 1989


In article <463 at sunset.MATH.UCLA.EDU> tony at joshua.math.ucla.edu writes:
>Can somebody e-mail me C routines that copies (or compares) two
>structures of the same type?
>


If your compiler will pass structures you can create a routine like the
one which follows to copy structures.

struct foo CopyStruct(struct foo Thing)
{
  return(Thing) ;
  }


Now if you don't want to write a routine for each type of structure you
wish to copy you could just copy it char by char.  As far as comparing,
I think there might be a probablem in comparing byte by byte in that
their could be unused space (well it is used for alignment) which might
contain different values even though two different structure are the same
member for member.  What does the proposed ANSI spec say (BTW, when well
it not be proposed anymore?) and what do older compilers do?

					  Mike



More information about the Comp.unix.xenix mailing list