March 7th, 2006, 03:02 AM
Difference between memmove and memcpy
When i was going through some book they have given an explanation about memmove and memcpy.
It copies count characters from the array pointed from source to destination. If the array overlaps the behaviour of memcpy is undefined.
It copies count characters from the array pointed from source to destination. If the array overlaps the copy will take place correctly.
In the above explanation i am not able to understand what they mean by array overlaps. It will be nice if any one give some detail explanation for that.
March 7th, 2006, 03:26 AM
Basically, it's saying that &foo + 10 bytes is past &foo
char foo = "hello world";
memmove ( &foo, &foo, 10 );
So part of what you're copying from will eventually get overwritten. It is vitally important then that you do the copying in the right order to avoid losing data.
memmove guarantees that this will happen
memcpy does not.