www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/19/03:54:31

From: alaric AT abwillms DOT demon DOT co DOT uk (Alaric B. Williams)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Messing with strings
Date: Wed, 19 Mar 1997 06:52:18 GMT
Message-ID: <332efc8e.10220125@news.demon.co.uk>
References: <01bc332c$d1b4dcc0$452349c2 AT default>
NNTP-Posting-Host: abwillms.demon.co.uk
Lines: 32
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 17 Mar 1997 23:42:20 GMT, "Thomas Harte" <T DOT Harte AT btinternet DOT com>
wrote:

>	Anyway, I want to know, how, in DJGPP, do you shift every value of a
>variable down one in a dimension, ie so that the value at x[n] is written
>to x[n+1], the value at x[n+1] to x[n+2], and so on. I could write a
>for/next routine type thing, but this would be slow. Is there a way similar
>to memcpy ? Like I said, on other compilers because I did not know the
>command, I would just mess with the positions in RAM, but that is not
>something I can get to work under protected mode.

Hmm, for an array A of length L:

memmove(A+1,A,(L-1)*sizeof(A[0]));

memmove differs from memcpy in that it is guaranteed to work for
overlapping blocks such as this. This makes it a little slower, but it
will work in the above case; memcpy merely /might/ :-)


ABW
--
"Plug and Play support: WfEWAD will autodetect any installed
Nuclear Arsenals, Laser Satellites, Battlefield Control Networks,
Radar Installations, Fighter Squadrons, and other WfEWAD compliant
devices, including the new Macrosoft Unnatural Keyboard, with
full support for the now-famous Big Red Buttom(tm)."

(Windows for Early Warning and Defence User's manual P26)

Alaric B. Williams Internet : alaric AT abwillms DOT demon DOT co DOT uk
<A HREF="http://www.abwillms.demon.co.uk/">Hello :-)</A>

- Raw text -


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