InterviewSolution
| 1. |
What Is The Difference Between A String Copy (strcpy) And A Memory Copy (memcpy)? |
|
Answer» Generally SPEAKING, they both copy a number of bytes from a source POINTER to a destination pointer. But the basic difference is that the strcpy() is specifically designed to copy strings, hence it stops COPYING after getting the first ''(NULL) character. But memcpy() is designed to work with all data TYPES. So you need to SPECIFY the length of the data to be copied, starting from the source pointer. Generally speaking, they both copy a number of bytes from a source pointer to a destination pointer. But the basic difference is that the strcpy() is specifically designed to copy strings, hence it stops copying after getting the first ''(NULL) character. But memcpy() is designed to work with all data types. So you need to specify the length of the data to be copied, starting from the source pointer. |
|