Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 8:44 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 3 posts ] 
Author Question
 Question subject: What is the size of this Structure
PostPosted: Fri May 08, 2009 7:09 am 
Offline
Newbie
User avatar

Joined: Fri May 08, 2009 7:07 am
Posts: 4
Has thanked: 0 time
Have thanks: 0 time

Quote:
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?


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: What is the size of this Structure
PostPosted: Sun May 10, 2009 12:28 am 
Offline
Moderator
User avatar

Joined: Fri Nov 21, 2008 6:18 pm
Posts: 51
Location: thessaloniki
Has thanked: 0 time
Have thanks: 2 time
its 8 that means that its 4 bytes

_________________
if you want make an effort yourself no one will make it for you...
best regards


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: What is the size of this Structure
PostPosted: Sun May 10, 2009 11:08 am 
Offline
Newbie
User avatar

Joined: Fri May 08, 2009 7:07 am
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
biskot188 wrote:
its 8 that means that its 4 bytes

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


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 3 posts ] 
Quick reply


  

 Similar topics
 ASP file structure
 Control font size of sub and sup text
 Set image size as a percentage of the page size
 Auto image size
 set the size of border in pixels
 Array size to zero
 change font size in JavaScript
 How to write C++ code that defines array of size 24 then;
 get Folder path and size
 How to use Javascript animation to change the size of a div?

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team