I understand the difference between memcpy
and memmove
: memmove
handles the overlapping of src
and dst
. I checked the man page for bcopy
and it seems to also handle overlapping. So I'm wondering if there is any difference between memmove
and bcopy
?

- 349,597
- 67
- 533
- 578

- 133
- 7
-
2This function is deprecated (marked as LEGACY in POSIX.1-2001): use memcpy(3) or memmove(3) in new programs. – Jan 05 '21 at 18:20
-
1I note that `memove` and `memcpy` are part of the C standard library, but `bcopy` is specific to POSIX so it won't be available on non-POSIX platforms like Windows. – Dai Jan 05 '21 at 18:20
-
2You will still find `bcopy`, `bzero`, etc.. in old code. (especially networking code for some reason). Those have gone the way of the Dodo and the `mem...()` functions should be used now. – David C. Rankin Jan 05 '21 at 18:24
3 Answers
bcopy
and memmove
do exactly the same thing. However, they take arguments in a different order: bcopy(src, dest, n)
vs memmove(dest, src, n)
. So they can't be two names for the same function.
Historically, bcopy
is the older of the two; it was present in 3BSD if memory serves. memmove
was invented by the C committee in 1988 or so.
New code should use memmove
, as it is required by the C standard and therefore more portable than bcopy
.

- 135,547
- 38
- 252
- 361
The main difference normally comes from their origin. bcopy
comes from Berkeley Source Distribution (BSD) systems, while memcpy
and their family come mainly from AT&T's System V. And finally, by complying with legacy code, all those functions were included in the standards.
There's a good explanation about the use of memset
vs bzero
in Richard Steven's book "UNIX network programming" that somewhat explains about the use of either one.
Today implementations just resolve to calling the same internal implementation but providing both interfaces.

- 10,974
- 1
- 16
- 31
Functionally they are equivalent. The difference is in portability. memmove
is part of the C standard while bcopy
is part of POSIX, and is therefore less portable.
bcopy
is deprecated. The man page says:
This function is deprecated (marked as LEGACY in POSIX.1-2001): use
memcpy(3)
ormemmove(3)
in new programs. Note that the first two arguments are interchanged formemcpy(3)
andmemmove(3)
. POSIX.1-2008 removes the specification ofbcopy()
.

- 349,597
- 67
- 533
- 578