Consider this code:
If I compile this with Microsoft (Visual Studio .net) compiler and execute I get this result: Sizeof structure element is: 8 bytes!.
typedef struct element
struct element* next;
printf("Sizeof structure element is: %d bytes!",sizeof(element));
But if I compile this with Borlan Turbo C compiler I get this:
Sizeof structure element is: 3 bytes!.
I'm using Win XP. I know that Turbo C was used under DOS. In TC sizeof(void*) is 2 bytes which means that it behaves like it is run under 16-bit operating system. Win XP is 32 bit OS and in TC is probably 16-bit application and that's why I get these results. Can you confirm this conclusion?
What is interesting is somewhat unexpected result when using Visual Studio's compiler: 8 bytes and one could expect 5 bytes. Is that mean that structures can be only a multiple of 4. Why is that?
Thanks for help!