Linux-Hams archive - July 1998: sizeof()

sizeof()

Karl F. Larsen (xxl@elko.lt)
Sun, 5 Jul 1998 06:17:21 -0600 (MDT)


I am learning to write C and yesterday tried to write a program
that used sizeof() and it is broken in my version of compiler. No matter
what kind of variable, the Linux sizeof() returns 4. I went back to my old
Borland DOS compiler and it works there.

Please write this simple program on your Linux and see what you
get:

/* checks the function sizeof() */
#include <stdio.h>
int main(void)
{
printf("The size of an integer is %d bytes.\n", sizeof(int));
return 0;
}

This prints 4 in Linux and 2 (which is correct) using Borland C++.

Best wishes

- Karl F. Larsen, 3310 East Street, Las Cruces,NM (505) 524-3303 -