karthikbalaguru wrote:
> I find that the structure padding is not being taken into account
> while using 'new' operator.
> Is there a way to enable it ?
>
> struct Dataunit
> {
> char dataid[20];
> int keyid;
> float result;
> } *p2;
>
> p2 = new Dataunit; // This is allocating 26 bytes.
>
> This allocates 26 bytes. Strange . :(:(.
Why is it strange? On a system where sizeof(int) == 2 that's what I'd
expect...
> Does C++ skip the Structure Padding concept while allocation of memory
> using 'new' ?
Well, the code you posted does not compile. Please post a compilable
example. Padding is implementation-specific. Please at least name the
compiler you're using. How do you determine how many bytes the 'new'
allocates and what did you expect, and why are they different (if they
are different)?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask