Xref: utzoo comp.lang.c:16529 comp.sources.wanted:6528 comp.unix.xenix:5118 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!oberon!oxy!bagpiper From: bagpiper@oxy.edu (Michael Paul Hunter) Newsgroups: comp.lang.c,comp.sources.wanted,comp.unix.xenix Subject: Re: Looking for memcpy() and memcmp() routines in C Message-ID: <20598@tiger.oxy.edu> Date: 25 Feb 89 20:43:04 GMT References: <463@sunset.MATH.UCLA.EDU> Organization: Occidental College, Los Angeles, CA 90041 Lines: 24 In article <463@sunset.MATH.UCLA.EDU> tony@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