<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Andrew Kohlsmith wrote:
<blockquote cite="mid200501190734.46421.akohlsmith-asterisk@benshaw.com"
type="cite">
<pre wrap="">On January 19, 2005 12:00 am, Edwin Groothuis wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Any C programmer who checks with strlen() if the length of a string
is greater than zero should be forced to read the K&R book again
to understand how the C programming language actually works.
</pre>
</blockquote>
<pre wrap=""><!---->
Save me a trip to the library and tell me when strlen() would not return the
length of a string?
I've been a C programmer for over a decade now and can't think of a reason why
this would be considered a bad thing. At the very heart of strlen would be a
loop something along the line of
int count = 0;
while (*(string++))
count++;
Yes my C's getting rusty but can you think of a better/faster way to count the
characters in a zero-terminated string?
</pre>
</blockquote>
<br>
If you just want to check if string is bigger than 0, just check:<br>
<br>
if ( *str )<br>
{<br>
blah-blah-blah;<br>
blah-blah-blah;<br>
blah-blah-blah;<br>
}<br>
<br>
in this case you will save lots on CPU cycles.<br>
<br>
<br>
<br>
All the Best!<br>
Sergey.<br>
</body>
</html>