我想查看计算机上数据类型的大小。 因此,我从使用以下代码的int数据类型开始:
#include <iostream>
using namespace std;
int main()
{
int t, *tpntr1, *tpntr2;
tpntr1 = &t;
cout << "The first address: \t" << tpntr1;
tpntr2 = ++tpntr1;
cout << "\n The second address : \t" << tpntr2;
unsigned int size= (tpntr2 - tpntr1);
cout << "\n the size of int : \t" << size<<"\n";
return 0;
}
在Visual Studio中编译后,大小返回为0。在特定的运行中,第一个地址为0028FBA4,第二个地址为0028FBA8,但差值为零。 有人可以指出我在做什么错吗? 我猜它与十六进制到十进制转换有关。