On Mon Jun 21, 2004 at 14:28:15 +1000, Rajnish Tiwari wrote:
>Hi All,
>
>In C, I have the following declaration:
>
>int foo()
>{
>  char* bar;
>
>
>};
>
>If unitialised, what the the value of variable "bar" ?
>Will it get initialised to 0 or be a random value ?
>Is the value allocated at runtime or compile time ?

Well it isn't going to be random exactly. But it is going
to be undefined. (It will be whatever happens to be on your
stack at the time.)

Anyway, unitialised means undefined. If you want it to be zero you
need

char *bar = NULL;

Cheers,

Benno
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to