C尺度范例的长度bytes
WIN2K/VC下面:
[char] Size Total:1
[int] Size Total:4
[long int] Size Total:4
[float] Size Total:4
[double] Size Total:8
[long double] Size Total:8
[double point]Size Total:4
[char point] Size Total:4
WIN2K/dev-c++下面 &
Ubuntu8.10 gcc 下面:
[char] Size Total:1
[int] Size Total:4
[long int] Size Total:4
[float] Size Total:4
[double] Size Total:8
[long double] Size Total:12
[double point]Size Total:4
[char point] Size Total:4
SUN Ultra10 Solairs8(32bit)GUNgcc:
[char] Size Total:1
[int] Size Total:4
[long int] Size Total:4
[float] Size Total:4
[double] Size Total:8
[long double] Size Total:16
[double point]Size Total:4
[char point] Size Total:4
结论 long double范例,Solairs的gcc下最长;VC最短。科学计较慎用VC。
#include <math.h>
#include <stdio.h>
main()
{
char c;
int i;
long int j;
float k;
double l;
long double m;
char *cp;
double *lp;
printf("[char] Size Total:%d\n",sizeof(c));
printf("[int] Size Total:%d\n",sizeof(i));
printf("[long int] Size Total:%d\n",sizeof(j));
printf("[float] Size Total:%d\n",sizeof(k));
printf("[double] Size Total:%d\n",sizeof(l));
printf("[long double] Size Total:%d\n",sizeof(m));
printf("[double point]Size Total:%d\n",sizeof(cp));
printf("[char point] Size Total:%d\n",sizeof(lp));
printf("\nThe done.\n");
getc(stdin);
}