- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int cal(int,int);
- int cal(int,int,int);
- int main()
- {
- int intVar=10;
- float floatVar=3.14f;
- double doubleVar=3.14159;
- long double longdVar=5.378e+300;
- string strVar1="我是字串";
- char strVar2[]="我是字元陣列";
- cout<<"變數名稱\t變數位址\t所占空間"<<endl;
- cout<<"---------------------------------------"<<endl;
- cout<<"intVar \t"<<&intVar<<"\t"<<sizeof(intVar)<<"位元組"<<endl;
- cout<<"floatVar \t"<<&floatVar<<"\t"<<sizeof(floatVar)<<"位元組"<<endl;
- cout<<"doubleVar\t"<<&doubleVar<<"\t"<<sizeof(doubleVar)<<"位元組"<<endl;
- cout<<"longdVar \t"<<&longdVar<<"\t"<<sizeof(longdVar)<<"位元組"<<endl;
- cout<<"strVar1 \t"<<&strVar1<<"\t"<<sizeof(strVar1)<<"位元組"<<endl;
- cout<<"strVar2 \t"<<&strVar2<<"\t"<<sizeof(strVar2)<<"位元組"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |