Help needed with: sizeof (struct a)

Dave Corcoran dave at aspect.UUCP
Thu Jun 20 03:07:13 AEST 1991


printf("Hello World\n");

My Sun cc prints 4 for both structs, prints 3 for the array

-----------------8<-------------------- 
struct a {char x;char y;char z};
struct b {char x[3]};
char c[3];
main()
{
	printf("%d\n",sizeof (struct a));
	printf("%d\n",sizeof (struct b));
	printf("%d\n",sizeof c);
}
-----------------8<--------------------

Is there any way to cause cc to force sizeof return the actual size of the
structs without rounding up to the next highest sizeof (short)?
Thanx
-- 
David Corcoran		      -@@
uunet!aspect!dave	        ~
Having the right to do something is not the same as being right in doing it.
					--  C.K. Chesterson



More information about the Comp.lang.c mailing list