C++ int folat不同编辑器下占字节数
C++ int folat不同编辑器下占字节数
不同编辑器下,变量占用内存字节数不同:
VC(VS)下:
[code = "c++"]
#include<iostream>
using namespace std;
int main(void)
{
cout << "int = " << sizeof(int) << endl;
cout <<"float = " << sizeof(float) << endl;
cout <<"short = " << sizeof(short) << endl;
cout <<"double = " << sizeof(double) << endl;
cout <<"char = " << sizeof(char) << endl;
return 0;
}
int = 4
float = 4
short = 2
double =
char = 1
而在TC环境下:int = 2,其他相同;