delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/09/08:10:40

From: Martin DOT Stromberg AT lu DOT erisoft DOT se (Martin Stromberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: memcpy() vs memmove()
Date: 9 Dec 1998 12:36:58 GMT
Organization: Ericsson Erisoft AB, Sweden
Lines: 32
Message-ID: <74lqta$l3o$1@antares.lu.erisoft.se>
References: <74ll3i$h7k$1 AT hermes DOT is DOT co DOT za>
NNTP-Posting-Host: juno.lu.erisoft.se
X-Newsreader: TIN [version 1.2 PL2]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Freddie Schwenke (freddie DOT schwenke2 AT sanlam DOT co DOT za) wrote:
: I'm using DJGPP to learn C.  I also want to use this tool to train people in
: C.  I came accross a problem when I tried the memcpy() and memmove()
: functions tho'.

: memmove() seems to do what it is supposed to do.  I have no problem with
: that.

: memcpy() gives some weird results tho'.

:   char
:     buffer[11] = "abcdefghij";

:   memcpy(buffer + 1, buffer, 9);

: Should this not result in buffer = "aaaaaaaaaa"???

: Well it does...IF the string contains a maximum of 15 characters (excluding
: the null character).  The moment the length exceeds 15 characters I get
: weird results.

: Any suggestions or comments will be appreciated.

Well, learn to read the man page. memmove's page says that overlapping 
regions will be copied correctly. There are no such statement for memcpy
although it says the function works as efficiently as possible (i. e. 
indeterminate results if overlapping regions.


Right,

							MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019