Which function is generally used to copy a specified number of bytes from one memory area to another?
Options
- A. memcpy()
- B. strlen()
- C. realloc()
- D. More than one of the above
- E. None of the above
Quiz Practice:
A. memcpy()
Answer: (A) memcpy()
memcpy() is a memory manipulation function used to copy a specified number of bytes from one memory area to another.
Its basic form is memcpy(destination, source, number_of_bytes).
It is different from strlen(), which is used to determine the length of a null-terminated C-style string.
When using memcpy(), the programmer must ensure that the source and destination memory regions are valid and appropriately sized.