Thursday, April 27, 2017

memcpy vs strcpy

The functions which begins with "mem" prefix also operate on characters but, they do not use the null terminator convention.

This is the reason they will always need the size of characters to operate on.

For example, when using memcpy it requires size as well, though, strcpy only needs dest and src pointers. It can automatically detect end of string using null character.

void *memcpy(void *dest, const void *src, size_t n);
 
char *strcpy(char *dest, const char *src); 

No comments:

Post a Comment