|
From: Ioannis V. <iv...@em...> - 2003-07-15 00:44:23
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Per Westermark > Sent: Tuesday, July 15, 2003 2:47 AM > To: Shane Bryldt > Cc: Jaap de Wolff; C++ > Subject: Re: [Dev-C++] STL Map question > > > In your text you mentioned something about the original code zeroing > arrays on erase and performing reallocation. > > Just a note about a very important difference between C and > C++. In C it > is always safe to use memset() or ZeroMemory etc to clear a struct You are in general right with an exception. 0 value is not necessarily in all types all bits zero (which is the 0 of a char/byte). Also a struct or a type may have padding bits and 0ing all its bytes calls for trouble. Regarding C99 I have read in Usenet (but was too bored to check the standard) that char can have padding bits because they believed that C90 allowed that, while C++ inherited from C90 the fact that a char cannot have padding bits. That's funny eh? Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |