当前位置:网站首页>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);
}
边栏推荐
- 841. String hash
- 力扣 2315.统计星号
- vulnhub之school 1
- ASP.NET幼儿园连锁管理系统源码
- MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
- 国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
- Openeuler prize catching activities, to participate in?
- pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
- Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
- 九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
猜你喜欢
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
J ü rgen schmidhub reviews the 25th anniversary of LSTM papers: long short term memory All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversar
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
Compiler optimization (4): inductive variables
数据孤岛是企业数字化转型遇到的第一道险关
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
编译器优化那些事儿(4):归纳变量
Some important knowledge of MySQL
多个线程之间如何协同
论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
随机推荐
Tp6 realize Commission ranking
一文读懂数仓中的pg_stat
9 atomic operation class 18 Rohan enhancement
8 CAS
My creation anniversary
CUDA versions are inconsistent, and errors are reported when compiling apex
Make this crmeb single merchant wechat mall system popular, so easy to use!
R语言dplyr包mutate_at函数和min_rank函数计算dataframe中指定数据列的排序序号值、名次值、将最大值的rank值赋值为1
tp6 实现佣金排行榜
The project manager's "eight interview questions" is equal to a meeting
使用高斯Redis实现二级索引
关于自身的一些安排
力扣 1961. 检查字符串是否为数组前缀
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
Semantic slam source code analysis
Ways to improve the utilization of openeuler resources 01: Introduction
Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
编译器优化那些事儿(4):归纳变量