数据类型所占用内存的大小

数据类型所占的大小是由编译器和你电脑的架构共同决定的。

举个例子: 定义一个int x=0;

那么怎么去查看到底这个int型的x变量占用的内存大小呢?

c++中提供了sizeof这个函数。

我们可以打印sizeof(x)去验证,我的电脑上,Visual Studio2013环境中,x变量占用4个bytes。

 

You may be surprised to find that the size of a given data type is dependent on the compiler and/or the computer architectureint!

posted @ 2017-05-12 10:04  L.A.Wang  阅读(569)  评论(0)    收藏  举报