Quote:
|
Originally Posted by Jimbo
somewhat simplified: NULL = 0 = '\0'
|
Well, that is extremely simplified, because you can't do this:
char *ptr;
if ( ptr == '\0' );
To darksabbath:
If you want to check the
value of a pointer, use NULL. If you want to check the
value at the address a pointer points to, use '\0'.
In your first example while((*s = *t) != '\0') was correct and that's how I would do it. Jimbo's method is perfectly fine too.
[EDIT]
Though, I will mention that the statement while((*s = *t) != '\0') will overwrite memory
before checking the value, which isn't very good practice IMO.
[EDIT v2]
And that's why there is a strncpy(), so while my first edit was valid, it is irrelevant with respect to the strcpy function.
I think I'll stop now...
