Xref: utzoo comp.lang.c:16256 comp.sources.wanted:6365 comp.unix.xenix:4984 Newsgroups: comp.lang.c,comp.sources.wanted,comp.unix.xenix Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Looking for memcpy() and memcmp() routines in C Message-ID: <1989Feb15.201133.16123@utzoo.uucp> Organization: U of Toronto Zoology References: <463@sunset.MATH.UCLA.EDU> Date: Wed, 15 Feb 89 20:11:33 GMT In article <463@sunset.MATH.UCLA.EDU> tony@MATH.UCLA.EDU () writes: >Can somebody e-mail me C routines that copies (or compares) two >structures of the same type? Copying is fairly trivial; in fact, struct assignment is part of most C compilers (although if he's got a real antique it may not be there). Just "a = b;" where a and b are structs of the same type. Nobody is going to be able to mail you C routines that reliably and portably compare two structures of the same type, because it can't be done without a member-by-member comparison. The compiler is entitled to insert "holes" into a structure to meet alignment requirements for following members, and there is no guarantee that those holes will contain the same data in all structs, so a simple compare-N-bytes function is not good enough. -- The Earth is our mother; | Henry Spencer at U of Toronto Zoology our nine months are up. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu