473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Strcut padding?

#include <iostream>
#include <string>

using namespace std;

int main() {
char t1;
struct t2{
char x;
};

cout << sizeof(t1) << " " << sizeof(t2) << endl;

typedef char& x1;
struct x2{
x1 x;
};

cout << sizeof(x1) << " " << sizeof(x2) << endl;
}

output:
1 1
1 4

Can anybody tell me why the size of x2 is 4? Why it's not 1?
Feb 23 '08 #1
0 1961

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Red | last post by:
This is apparently an ie display bug, I can't seem to figure out which ie bug this is. a 3 sided border is created by wrapping the 'inner' box in the 'middle' box and padding the 'middle' box...
2
by: Knoxy | last post by:
Hello, I've noticed one or two people post on this before but nobody seems to have replied so raising the issue again... is this a known IE6 CSS bug? I have placed the following in my...
4
by: Wilhelm Kutting | last post by:
hi, when i use the padding-left attribut, i like to overwrite a default value like that ..padding30 {margin-left: 30px;} ..padding0 {margin-left: 0px;} <div class="padding30"> Padding 30...
13
by: Amarendra | last post by:
Folks, This structure padding issue is bothering me now, could not locate a satisfactory answer on clc, so here it goes... I have a structure, given below: typedef struct { int flag; char...
36
by: phil-news-nospam | last post by:
Here is a simpler (no drop shadows) example of the padding bug I see: http://phil.ipal.org/usenet/ciwas/2006-05-08/buttons-1.html So far I find nothing in the CSS2 document that says I should...
11
by: john_aspinall | last post by:
I want to put a simple padding on the right hand side of my text container to stop the text from overflowing out of the box. Ive added a padding-right rule and it refusing to recognise it in...
5
by: Hallvard B Furuseth | last post by:
Does struct assignment copy padding bytes? Some compilers do, but I couldn't find anything in the standard which says they must. What I need is for any padding bytes to contan initialized values...
12
by: Kislay | last post by:
case 1 : struct s { char c1; // 8 double d; // 8 int i1; // 4 char c2; // 4 int i2; // 4 };
6
by: maya | last post by:
hi, I recently discovered the hard way that when you had padding-right or padding-left to a div it increases the with of the div... how do you add left-padding or right-padding to a div w/o...
3
by: vippstar | last post by:
Hey comp.lang.c I'm somewhat confused with bit padding. I tried searching the FAQ, but there isn't a search feature, so I used google and the search query: site:c-faq.com padding. I did not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.