標題:
計算資料型別記憶體位置
[打印本頁]
作者:
周政輝
時間:
2017-7-4 18:33
標題:
計算資料型別記憶體位置
利用sizeof()計算每一個資料型別佔記憶體當中的幾Byte
作者:
顏羽彤
時間:
2017-7-4 18:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"int:"<<sizeof(int)<<"byte"<<endl;
cout<<"float:"<<sizeof(float)<<"byte"<<endl;
cout<<"string:"<<sizeof(string)<<"byte"<<endl;
cout<<"char:"<<sizeof(char)<<"byte"<<endl;
cout<<"double:"<<sizeof(double)<<"byte"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張閎鈞
時間:
2017-7-4 18:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"int"<<sizeof(int)<<endl;
cout<<"char"<<sizeof(char)<<endl;
cout<<"string"<<sizeof(string)<<endl;
cout<<"float"<<sizeof(float)<<endl;
cout<<"double"<<sizeof(double)<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林峻安
時間:
2017-7-4 18:37
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout<<"int:"<<sizeof(int)<<endl;
cout<<"char:"<<sizeof(char)<<endl;
cout<<"string:"<<sizeof(string)<<endl;
cout<<"float:"<<sizeof(float)<<endl;
cout<<"double:"<<sizeof(double)<<endl;
system("pause");
return 0;
}
複製代碼
作者:
巫晉宇
時間:
2017-7-4 18:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"int:"<<sizeof(int)<<endl;
cout<<"char:"<<sizeof(int)<<endl;
cout<<"string:"<<sizeof(int)<<endl;
cout<<"float:"<<sizeof(int)<<endl;
cout<<"double:"<<sizeof(int)<<endl;
system("pause");
return 0;
}
作者:
巫沛庭
時間:
2017-7-4 18:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"int:"<<sizeof(int)<<endl;
cout<<"char:"<<sizeof(char)<<endl;
cout<<"float:"<<sizeof(float)<<endl;
cout<<"double:"<<sizeof(double)<<endl;
cout<<"string:"<<sizeof(string)<<endl;
system("pause");
return 0;
}
作者:
張凱婷
時間:
2017-7-4 18:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"int:"<<sizeof(int)<<"byte"<<endl;
cout<<"float:"<<sizeof(float)<<"byte"<<endl;
cout<<"string:"<<sizeof(string)<<"byte"<<endl;
cout<<"char:"<<sizeof(char)<<"byte"<<endl;
cout<<"double:"<<sizeof(double)<<"byte"<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2