<sizeof演算子のサンプル>
#include <stdio.h>
#include <limits.h> /*CHAR_BIT*/
void main(void)
{
printf ("------------------------\n");
printf ("char %d bits\n",CHAR_BIT);
printf ("------------------------\n");
printf ("char %d bytes\n",sizeof(char));
printf ("unsigned char %d bytes\n",sizeof(unsigned char));
printf ("short %d bytes\n",sizeof(short));
printf ("unsigned short %d bytes\n",sizeof(unsigned short));
printf ("int %d bytes\n",sizeof(int));
printf ("unsigned int %d bytes\n",sizeof(unsigned int));
printf ("long %d bytes\n",sizeof(long));
printf ("unsigned long %d bytes\n",sizeof(unsigned long));
printf ("float %d bytes\n",sizeof(float));
printf ("double %d bytes\n",sizeof(double));
printf ("long double %d bytes\n",sizeof(long double));
printf ("------------------------\n");
printf ("何かキーを押してください。");
getchar();
}
|