- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int intVar=10;
- float flaotVar=3.14;
- double doubleVar=3.14159;
- long double longdVar=1.276e+3000;
- string strVar="字串";
- char strVar2[5]="字元";
- cout<<&intVar<< " 佔"<<sizeof(intVar)<<"位元"<<endl;
- cout<<&flaotVar<< " 佔"<<sizeof(flaotVar)<<"位元"<<endl;
- cout<<&doubleVar<< " 佔"<<sizeof(doubleVar)<<"位元"<<endl;
- cout<<&longdVar<< " 佔"<<sizeof(longdVar)<<"位元"<<endl;
- cout<<&strVar<< " 佔"<<sizeof(strVar)<<"位元"<<endl;
- cout<<&strVar2<< " 佔"<<sizeof(strVar2)<<"位元"<<endl;
- }
複製代碼 |