> Every iteration of the loop causes you to run
> another loop just to determine the string's length.  Since 
> you aren't
> changing the length within the loop, the extra loop is 
> pointless.

The strlen() should certainly be outside the loop. But you 
don't actually need to know the length of the string; you 
just need to step through it until you reach its zero 
terminator. This is easy if you use a 'while' loop instead 
of a 'for' loop.

Maybe this is a bit low-level, but it's fast and a typical C 
idiom. See K&R for numerous examples.

David

Reply via email to