POV-Ray : Newsgroups : povray.off-topic : C++ questions : Re: C++ questions Server Time
7 Sep 2024 07:21:50 EDT (-0400)
  Re: C++ questions  
From: Darren New
Date: 25 Sep 2008 17:46:38
Message: <48dc06be@news.povray.org>
Slime wrote:
>> More exactly, in C at least, any variables allocated statically start with 
>> a default value of zero appropriate for their type. That includes static 
>> variables allocated inside a function.
> 
> 
> I was under the impression that global variables are initialized to zero, 
> but you can't trust local variables because the stack has whatever garbage 
> data was left on it from previously called functions.

Correct. I was also pointing out that they get initialized to the type's 
version of zero, whatever that might be. (I.e., pointers may not have 
all zero bits in them; they get initialized to null instead.) Rarely can 
you see this difference. :-)

And variables that are static but not global also get initialized.

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.