Hi Ludwig,<br><br>Don&#39;t use str unless you assign memory to it using the malloc call.<br><br>If its an array, like<br><br>char str[SIZE] = {0};<br><br>then you can directly use the strlen call...<br><br>Regards,<br>Arjun
<br><br><div><span class="gmail_quote">On 6/11/07, <b class="gmail_sendername">Ludwig Isaac Lim</b> &lt;<a href="mailto:ludz_lim@yahoo.com">ludz_lim@yahoo.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi Jessu:<br><br>--- &quot;Anand, Jessu&quot; &lt;<a href="mailto:Jessu.Anand@lsi.com">Jessu.Anand@lsi.com</a>&gt; wrote:<br><br>&gt; Hi Ludwig,<br>&gt; You can initialize it by<br>&gt; Str = NULL;<br>&gt;<br>&gt; And later filling the characters, append &#39;\0&#39; to the end
<br>&gt; of it.<br>&gt;<br>&gt; Regards,<br>&gt; Jessu.<br><br>&nbsp;&nbsp; Thanks for the quick reply. Unfortunately it doesn&#39;t<br>work.<br><br>&nbsp;&nbsp; For example the following program will produce a<br>segmentation fault:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;int main()<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *c;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c = NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;%d&quot;,strlen(c));<br><br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp; I expect the output to be zero, but it produces a<br>segmentation fault everytime I ran it.
<br><br>regards,<br>ludwig<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;____________________________________________________________________________________<br>Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
<br><a href="http://autos.yahoo.com/green_center/">http://autos.yahoo.com/green_center/</a><br><br>_______________________________________________<br>This is the Linux C Programming List<br>:&nbsp;&nbsp;<a href="http://lists.linux.org.au/listinfo/linuxcprogramming">
http://lists.linux.org.au/listinfo/linuxcprogramming</a> List<br></blockquote></div><br><br clear="all"><br>-- <br>And it&#39;s whispered that soon, if we all call the tune,<br>Then the piper will lead us to reason<br>And a new day will dawn for those who stand long
<br>And the forest will echo with laughter<br><br><a href="http://freeshells.ch/~phoenix">http://freeshells.ch/~phoenix</a>