Hi,

Here is my program. I run this on every box I ever work on: Dos, MVS, OS2, RS/6000, Dec Alpha, and Linux.

And it works on everybox,

Here is my output from my Linux box (an intel 486, running RedHat 5.1)

Size of int = 4
Size of short = 2
Size of long = 4
Size of unsigned int = 4
Size of unsigned short = 2
Size of unsigned long = 4
Size of float = 4
Size of double = 8
Size of char = 1

Here is the program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
printf("\nSize of int = %d", sizeof(int));
printf("\nSize of short = %d", sizeof(short int));
printf("\nSize of long = %d", sizeof(long int));
printf("\nSize of unsigned int = %d", sizeof(unsigned int));
printf("\nSize of unsigned short = %d", sizeof(unsigned short));
printf("\nSize of unsigned long = %d", sizeof(unsigned long));
printf("\nSize of float = %d", sizeof(float));
printf("\nSize of double = %d", sizeof(double));
printf("\nSize of char = %d", sizeof(char));
printf("\n\n");

return(0);
}


On 6 Jul 98, at 6:40, Karl F. Larsen wrote:

>
> I have recieved many responses to my first message all saying it
> is proper for an int to have 4 bytes. So I went back to the original
> function that checks int, float, long and char. My GCC sizeof() says all
> these types use 4 byte! This just proves more fully that sizeof() is
> broken in my Linux. Here is the test program.
>
> /* prints out type sizes */
> #include <stdio.h>
> int main(void)
> {
> printf("Type int has a size of %d bytes.\n", sizeof(int));
> printf("Type long has a size of %d bytes.\n", sizeof(long));
> printf("Type float has a size of %d bytes.\n", sizeof(float));
> printf("Type char has a size of %d bytes.\n", sizeof(char));
> return 0;
> }
>
>
> Best wishes
>
> - Karl F. Larsen, 3310 East Street, Las Cruces,NM (505) 524-3303 -
>


              ///
             (. .)
    /=====oOO-(_)-OOo===========================\
   /                                             \
  /                  John Gorman                  \
  |         E-mail:  [EMAIL PROTECTED]        |
  |                                               |
  \        "We are what we repeatedly do."        /
   \                   Aristotle                 / 
    \===========================================/


Reply via email to