andreyvul wrote On 11/01/07 13:22,:
memmove won't work because it only works one byte at a time.
First, that may or may not be true. memmove() might
work one byte at a time, or forty-two bytes at a time, or
one bit at a time, or by slow seepage of quantum-encoded
information through a semi-permeable osmotic membrane.
It copies the source bytes to the destination, and there's
no need to fret about the mechanism.
Second, the mechanism can't be the reason why it "won't
work." I repeat: memmove() copies the source to the
destination, and that is all it does. If you don't like
the results, it means you have done something wrong, and
that the same thing would still be wrong if you replaced
memmove() by some other equivalent.
I'll try
changing the offset of the destination pointer by adding a sizeof.
I have, over the years, seen other people who tried this
same strategy for getting code to work. They'd just keep
making semi-random half-understood tweaks until they got the
answers they expected. Oddly enough, it nearly always turned
out that the tweaks produced code that worked only on the
single test case they'd tried, and quite often even that much
success was dumb luck (wander off the end of an array and just
happen to find something that looks like a bigger value than
anything in the array, that sort of thing).
You need to learn to *reason* about your code instead
of just diddling with it aimlessly.