delorie.com/archives/browse.cgi | search |
From: | "Freddie Schwenke" <freddie DOT schwenke2 AT sanlam DOT co DOT za> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: memcpy() vs memmove() |
Date: | Wed, 9 Dec 1998 14:54:51 +0200 |
Organization: | An Internet Solution Customer |
Lines: | 47 |
Message-ID: | <74lrv4$k9i$1@hermes.is.co.za> |
References: | <74ll3i$h7k$1 AT hermes DOT is DOT co DOT za> <74lqta$l3o$1 AT antares DOT lu DOT erisoft DOT se> |
NNTP-Posting-Host: | gauntlet-cpt.sanlam.co.za |
X-Newsreader: | Microsoft Outlook Express 4.72.2106.4 |
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.2106.4 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
I'm quite aware that there is a differrence between the two functions. I actually want to abuse the memcpy() function to replicate one ore more bytes throughout a string. The problem is that memcpy() only works while the length is less that 16. WHY??? Is this a C thing or a DJGPP thing? In MS Visual C++ apparently there is no difference betwee the two functions!!! Freddie :) Martin Stromberg wrote in message <74lqta$l3o$1 AT antares DOT lu DOT erisoft DOT se>... >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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |