[LCP] Newbie Question: Initializing empty/null string in C

Ludwig Isaac Lim ludz_lim at yahoo.com
Mon Jun 11 10:20:16 UTC 2007


Hi Jessu:

--- "Anand, Jessu" <Jessu.Anand at lsi.com> wrote:

> Hi Ludwig,
> You can initialize it by 
> Str = NULL;
> 
> And later filling the characters, append '\0' to the end
> of it.
> 
> Regards,
> Jessu.

   Thanks for the quick reply. Unfortunately it doesn't
work.

   For example the following program will produce a
segmentation fault:

    int main()
    {
       char *c;
       c = NULL;
       printf("%d",strlen(c));

    } 

   I expect the output to be zero, but it produces a
segmentation fault everytime I ran it.

regards,
ludwig


      ____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ 



More information about the linuxCprogramming mailing list