06 March, 2011

difference between strcpy() and memcpy()???

What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1 comment:

  1. Strcpy is use for copying only string from source to destination character buffer including NULL character also, whereas memcpy is used to copy any data type (void *) from source to destination , and the number of bytes copied from source to destination will be specified as the third argument of memcopy function.


    If a buffer contains more than one NULL pointer, in that case we can't use strcpy but we can use memcpy because strcpy will stop after first NULL character .

    ReplyDelete