Strange Result on Struct

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
Experienced poster
Posts: 101
Joined: Wed May 04, 2005 4:33 pm
Location: Tangerang, Banten, Indonesia

Strange Result on Struct

Post 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


struct da{
int a;
short b;

void main(){
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 :)

Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

Post by mf »

This question was asked just three days ago here.

Post Reply

Return to “C”