How do you copy memory every n bytes ?
Poor problem specification. For example, do you mean how do I copy n bytes of memory? Well, memcpy() works just dandy if the source and destination do not overlap, but it tends to have disastrous effects on smart pointers, whose use-count is not incremented by memcpy. If the source and destination overlap, you have to use memmove, which is much slower, but again messes up proper smart-pointer management. If you mean that you want to copy something out of every nth byte, for example, to copy every four-byte value spaced 20 bytes apart, that is trivial. You know how to copy four-byte values. You know how to increment the source address by 20. Done. Where do you put them? Well, they are four bytes wide. You know how to specify the destination address. You know how to add 4 to that value. Done. However, I would recommend using sizeof() or offsetof() to compute the positions so you dont have hardwired constants like 4 and 20 in your code, or even declared as const values or #defines. Those ways, madness lies. But I have to guess here, because the question is so badly presented. And dont forget: if you use smart pointers, memcpy is deadly.