C標準類型的長度bytes

來源:互聯網
上載者:User

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. }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.