[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
沒有留言:
張貼留言