arnuld said:
Is it pointless to check the return value of strcpy() (it will be
never be NUL anwyay). If yes, How can I be sure that contents are
successfully copied ?
The return value of strcpy() is a convenience only, allowing the address
of the target to be an expression and the return value to be the result
of evaluating that expression. One might well say that the return value
of strcpy() exists only because other functions like strcat, strchr,
strerror(), strpbrk(), strrchr(), strstr() return pointers to char. All
str* functions return some kind of value, and for consistency strcpy()
also returns one. I don't think that any of these return values are
used to represent an error condition (although the null pointer from
strchr, strrchr, strstr might be interpreted as such), so "checking" the
return value is usually a meaningless term.
Please note that "NUL" is _not_ a null pointer. The name used for the
null pointer, assuming it defined, usually by an appropriate header, is
"NULL". "NUL" is used with some character sets, not necessarily the one
used by any particular C implementation, as a name for the '\0'
character. It is a perhaps trivial point and perhaps unfair, but
misusing names in this way is one of the things by which people judge
you. And, no matter how much you think other people's judgments
unimportant, they can matter.