判断系统是32位还是64位

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/linxizi0622/article/details/72974438

直接上代码

#include <stdio.h>

#include <stdlib.h>


/* run this program using the console pauser or add your own getch, system("pause") or input loop */


int main(int argc, char *argv[]) {
int x=2;
char *y=&x;
//printf("%d",sizeof(y));
char *z=sizeof(y)==8?"该系统是64位":"该系统是32位";
printf("%s",z) ;
return 0;

}

切入点是,32位和64位表示的地址大小不一样,32位系统一个地址占4个字节

64位系统一个地址占8个字节

通过定义一个指针变量,来判断指针变量占内存空间大小

来判断系统是32位还是64位的

猜你喜欢

转载自blog.csdn.net/linxizi0622/article/details/72974438