- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
- int x[]={1,2,3,4,5,6,7,8,9,0};
- cout<<"int:"<<sizeof(int)<<endl;
- cout<<"string:"<<sizeof(string)<<endl;
- cout<<"char:"<<sizeof(char)<<endl;
- cout<<"float:"<<sizeof(float)<<endl;
- cout<<"double:"<<sizeof(double)<<endl;
- cout<<"陣列記憶體大小:"<<sizeof(x)<<endl;
- cout<<"int:"<<sizeof(int)<<endl;
- cout<<"陣列總長度"<<sizeof(x)/sizeof(int)<<endl;
- for(int i=0;i<sizeof(x)/sizeof(int);i++){
- cout<<x[i]<<",";
- }
- system("pause");
- return 0;
- }
複製代碼 |