Switch to full style
For C/C++ coders discussions and solutions
Post a reply

What is the size of this Structure

Fri May 08, 2009 7:09 am

Assuming 32 bit compiler, Unsigned int will take 4 bytes

Code:
Struct mystruct
{
   unsigned int bit0 : 1;
   unsigned int bit0 : 1;
   unsigned int bit0 : 1;
   unsigned int bit0 : 1;
   unsigned int bit0 : 1;
   unsigned int bit0 : 1;
   unsigned int bit0 : 1;
   unsigned int bit0 : 1;
}a;

I have the doubt,whether the sizeof structure is 1 byte or 4 byte?
Is sizeof(a)=1 or sizeof(a)=4?




Re: What is the size of this Structure

Sun May 10, 2009 12:28 am

its 8 that means that its 4 bytes

Re: What is the size of this Structure

Sun May 10, 2009 11:08 am

biskot188 wrote:its 8 that means that its 4 bytes

I have compiled the progrma and printed the sizeof(a).It is 1 byte.Not 4 bytes. Why is this so..


Post a reply
  Related Posts  to : What is the size of this Structure
 Set image size as a percentage of the page size     -  
 ASP file structure     -  
 c++/data structure     -  
 program using structure to store roll number,name     -  
 Display data from database as Tree Structure in JSP     -  
 Nav button size     -  
 Array size to zero     -  
 get string size in c++     -  
 Auto image size     -  
 preferred size of a component     -