View Single Post
Old May 24th, 2006, 5:38 AM   #9
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 769
Rep Power: 3 Jimbo is on a distinguished road
Quote:
Originally Posted by bivhitscar
Well, that is extremely simplified, because you can't do this:

char *ptr;
if ( ptr == '\0' );
Why not? It's a silly way of doing things, but what's stopping you?

Quote:
Originally Posted by bivhitscar
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.
I wouldn't say that it's bad practice, as it really depends on the algorithm. For instance, for strcpy() you want it to copy the last value, so there's nothing wrong with this. It is good to point out that the assignment happens, but it's only bad if you're not expecting it to.
Jimbo is offline   Reply With Quote