memset

C

CBFalconer

.... snip ...
7.21.2.2p2: "[...] Copying takes place as if the n
characters from the object pointed to by s2 are first
copied into a temporary array of n characters that does
not overlap the objects pointed to by s1 and s2, and
then the n characters from the temporary array are copied
into the object pointed to by s1."
.... snip ...

Is there a reason (well, a reason behind history, which is
probably the currently-live reason) why memmove does a non-
destructive copy instead of smearing? It seems, to my limited
imagination, that smearing would be a lot more useful.

If you examine Erics quote with care, you will notice the magic
phrase "as if". The thing that counts is the end result.
 
D

dj3vande

... snip ...
7.21.2.2p2: "[...] Copying takes place as if the n
characters from the object pointed to by s2 are first
copied into a temporary array of n characters that does
not overlap the objects pointed to by s1 and s2, and
then the n characters from the temporary array are copied
into the object pointed to by s1."
... snip ...

Is there a reason (well, a reason behind history, which is
probably the currently-live reason) why memmove does a non-
destructive copy instead of smearing? It seems, to my limited
imagination, that smearing would be a lot more useful.

If you examine Erics quote with care, you will notice the magic
phrase "as if". The thing that counts is the end result.

Yes.
My question was why it wasn't "as if by a simple byte-copying loop".
i.e. why the specified end result was what it is instead of something
else.

(Interestingly, the day after I claimed elsethread that I've
never-in-my-memory had a reason to use memmove, I ended up doing
exactly the array-shift that Eric used as an example of what it's
useful for. The universe definitely has a sense of humour this week.)


dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top