search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

[C/C++ 基礎]-證明所有指標變數大小一至且計算編譯器所編譯成是的定指空間大小 – jashliao部落格

[C/C++ 基礎]-證明所有指標變數大小一至且計算編譯器所編譯成是的定指空間大小

 

剛才寫的一個可以證明所有指標變數大小一至且計算編譯器所編譯成是的定指空間大小的範例,歡迎有興趣C/P同好,一起來C/P一下。

 

 

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
char *chr_pA;
int *int_pB;
double *dbl_pC;
int intD=0;
intD=sizeof(chr_pA);
cout << "char point size=" << intD << endl;
intD=sizeof(int_pB);
cout << "int point size=" << intD << endl;
intD=sizeof(dbl_pC);
cout << "double point size=" << intD <<endl;
cout << "The C++ compiler is " << (8*intD) << " Bits"<<endl;
cout << "The APP can use max of main memory size that is " <<pow((float)2,(float)(8*intD)) << " Bytes"  <<endl;
return 0;
}

線上執行結果網址:http://codepad.org/WAkwq3OD

 

 




熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦