Page 1 of 1

Strange Result on Struct

Posted: Fri Aug 18, 2006 7:50 am
by Roby
My friend of mine ask me about this code and I was unable to answer it why. Here's the code:

Code: Select all

#include<stdio.h>

struct da{
int a;
short b;
}asd;

void main(){
printf("%d",sizeof(asd));
}
It supposed to be 6 bytes, didn't it? But when my friend compiled it with GCC and VC++ 6, he got 8 bytes? Why?

Thanx in advance :)

Posted: Fri Aug 18, 2006 7:52 am
by mf
This question was asked just three days ago here.
http://online-judge.uva.es/board/viewtopic.php?t=11577