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。

  1. #include <math.h>
  2. #include <stdio.h>
  3. main()
  4. {
  5.  char c;
  6.  int i;
  7.  long int j;
  8.  float k;
  9.  double l;
  10.  long double m;
  11.  char *cp;
  12.  double *lp;
  13.  printf("[char]        Size Total:%d/n",sizeof(c));
  14.  printf("[int]         Size Total:%d/n",sizeof(i));
  15.  printf("[long int]    Size Total:%d/n",sizeof(j));
  16.  printf("[float]       Size Total:%d/n",sizeof(k));
  17.  printf("[double]      Size Total:%d/n",sizeof(l));
  18.  printf("[long double] Size Total:%d/n",sizeof(m));
  19.  printf("[double point]Size Total:%d/n",sizeof(cp));
  20.  printf("[char point]  Size Total:%d/n",sizeof(lp));
  21.     printf("/nThe done./n");
  22.  getc(stdin);
  23. }

posted on 2008-12-26 09:50  johnphan  阅读(165)  评论(0编辑  收藏  举报

导航