Hi Ludwig,<br><br>Don'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> <<a href="mailto:ludz_lim@yahoo.com">ludz_lim@yahoo.com</a>> 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>--- "Anand, Jessu" <<a href="mailto:Jessu.Anand@lsi.com">Jessu.Anand@lsi.com</a>> wrote:<br><br>> Hi Ludwig,<br>> You can initialize it by<br>> Str = NULL;<br>><br>> And later filling the characters, append '\0' to the end
<br>> of it.<br>><br>> Regards,<br>> Jessu.<br><br> Thanks for the quick reply. Unfortunately it doesn't<br>work.<br><br> For example the following program will produce a<br>segmentation fault:<br><br>
int main()<br> {<br> char *c;<br> c = NULL;<br> printf("%d",strlen(c));<br><br> }<br><br> 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> ____________________________________________________________________________________<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>: <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'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>