当前位置:网站首页>c语言如何判定是32位系统还是64位系统
c语言如何判定是32位系统还是64位系统
2022-07-07 18:01:00 【junxuezheng】
32位和64位指的是操作系统的位数,映射到C语言中,最直观的就是指针类型占用的字节数。
1、32位系统:
地址占32位,所以指针类型同样占32位,即4字节。
2、64位系统:
地址占64位,所以指针类型同样占64位,即8字节。
于是,只需要判断任意一个指针的sizeof值,即可获取到位数。
3、demo
#include <iostream>
using namespace std;
int main()
{
int bits = sizeof(char*);
if (bits == 4) printf("32位\n");
else if (bits == 8) printf("64位\n");
else printf("others, bits = %d\n", bits);
}
边栏推荐
- LC: string conversion integer (ATOI) + appearance sequence + longest common prefix
- Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
- Some important knowledge of MySQL
- 论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
- JVM GC垃圾回收简述
- JVM 类加载机制
- equals 方法
- 力扣 88.合并两个有序数组
- 线性基
- 8 CAS
猜你喜欢

9 atomic operation class 18 Rohan enhancement

LeetCode_7_5

PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!

mock.js从对象数组中任选数据返回一个数组

Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )

国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报

LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字

8 CAS
Make this crmeb single merchant wechat mall system popular, so easy to use!

华南X99平台打鸡血教程
随机推荐
力扣599. 两个列表的最小索引总和
PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
强化学习-学习笔记8 | Q-learning
Sword finger offer II 013 Sum of two-dimensional submatrix
Equals method
R language ggplot2 visualization: use the ggviolin function of ggpubr package to visualize the violin diagram, set the palette parameter to customize the filling color of violin diagrams at different
力扣 2315.统计星号
The project manager's "eight interview questions" is equal to a meeting
R language ggplot2 visualization: use the ggecdf function of ggpubr package to visualize the grouping experience cumulative density distribution function curve, and the linetype parameter to specify t
ASP. Net kindergarten chain management system source code
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
9 atomic operation class 18 Rohan enhancement
How to buy bank financial products? Do you need a bank card?
小试牛刀之NunJucks模板引擎
R语言dplyr包mutate_at函数和min_rank函数计算dataframe中指定数据列的排序序号值、名次值、将最大值的rank值赋值为1
位运算介绍
831. KMP字符串
使用高斯Redis实现二级索引
Version selection of boot and cloud
Mysql, sqlserver Oracle database connection mode