Computer Science, asked by nazmusmondal973, 1 year ago

What is the difference between a string copy(strcpy) and a memory copy(memcpy) in c?

Answers

Answered by VemugantiRahul
1
Hi there !
Here's the answer :


• If strcpy() is used, a string is copied until it comes across the termination character ‘\0’.
• When using memcopy(), the size of data to be copied must be specified by the programmer.
• strnncpy() is similar to memcopy() in which the programmer specifies n bytes that need to be copied.


The differences b/w strcpy() and memcpy():

• strcpy() is used to copy a constant / string into another string.
° memcpy() is used to copy specific number of bytes from source to destination in RAM.


• strcpy() works on null-terminated strings and it has no length limitations.
° memcpy() works on fixed length of arbitrary data.

• strcpy() is used of copy variable-length null terminated strings.
° memcpy() is used to copy the exact amount of data.


:)
Hope it helps
Similar questions