Disagreement about memcpy
Me and some other co-students we have a disagreement on checking the result of memcpy.
Based on these references
www.elook.org
www.cplusplus.com
some of us believe that one can't check if memcpy failed unless if after use it, compare using memcmp the destination with source.
ex :
Code:
memcpy(dest,source,Size);
if(memcmp(dest,source,Size) != 0)
puts("Memcpy failed");
Some other co-students believe that one can check if memcpy fail by comparing the return value with NULL.
ex.
Code:
if(memcpy(dest,source,Size) == NULL)
puts("Memcpy failed");
*Supose that dest/source/Size are valid
Finally i also think that there is no point on check memcpy as far as i pass valid arguments.
Precaution is better than treatment !!!
We need an opinion here :)