Tyler Littlefield wrote:
> it would've solved his problem of getting the loop done--feel free to make 
> your own suggestion. strlen isn't extremely costly to run, or we wouldn't 
> have it. Granted, he could just incriment a pointer and check to see if it's 
> null in the loop, but the for loop was an easier approach.
> 
> 
> 
> Thanks,
> Tyler Littlefield
> email: [EMAIL PROTECTED]
> web: tysdomain-com
> Visit for quality software and web design.
> skype: st8amnd2005

Wrong.  Check your algorithm again.  You are using strlen() in the 
conditional statement of the loop.  That IS expensive.  And bad 
programming practice (especially if you use it everywhere).  I did that 
years ago when I first started C.  I also learned real fast that doing 
that was a bad idea.  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.  If 
you are expecting the compiler to optimize that for you, it won't 
(unless you are doing the whole fancy Instrumented build thing - even 
then it might not get optimized out).

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to