菜菜

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

每台计算机都有字长,指明指针数据的标称大小----来自深入理解计算机系统

每台计算机的字长指明了它的虚拟空间大小.比如32位的机器,虚拟空间地址为0~2^w-1程序最多访问2^w个字节

对于32位程序和64位程序的区别在于如何编译.

gcc -m32 编译成32位程序

gcc -m64 编译成64位程序.

对于32位程序,虚拟地址空间最大是4GB.

所以有,以后代码在不同字长的计算机运行的结果是不同的.32位是4

#include <iostream>
#include <stdio.h>
#include<memory.h>
using namespace std;

#define null NULL

int f1(int a)
{
	return a;
}
void f2(int a)
{
	cout<<a<<endl;
}
int main(int argc,char* argv[])
{
	freopen("C:\\Users\\zzzzz\\Desktop\\1.txt", "r", stdin);
	double* pd;
	char* pc;
	float* pf;
	long long* pll;
	int* pi;
	void* pv;
	int (*fi)(int);
	void (*fv)(int);
	cout<< sizeof(pd)<<endl;
	cout<<sizeof(pc)<<endl;
	cout<<sizeof(pf)<<endl;
	cout<<sizeof(pll)<<endl;
	cout<<sizeof(pi)<<endl;
	cout<<sizeof(pv)<<endl;
	cout<<sizeof(fi)<<endl;
	cout<<sizeof(fv)<<endl;
	cout<<sizeof(null)<<endl;
	return 0;
}

  

posted on 2017-09-06 00:52  好吧,就是菜菜  阅读(5581)  评论(0编辑  收藏  举报