当前位置:网站首页>How C language determines whether it is a 32-bit system or a 64 bit system
How C language determines whether it is a 32-bit system or a 64 bit system
2022-07-07 20:11:00 【junxuezheng】
32 Bit and 64 Bit refers to the number of bits of the operating system , Mapping to C In language , The most intuitive is the number of bytes occupied by the pointer type .
1、32 Bit system :
Address 32 position , So the pointer type also accounts for 32 position , namely 4 byte .
2、64 Bit system :
Address 64 position , So the pointer type also accounts for 64 position , namely 8 byte .
therefore , You only need to judge the value of any pointer sizeof value , You can get the number of digits .
3、demo
#include <iostream>
using namespace std;
int main()
{
int bits = sizeof(char*);
if (bits == 4) printf("32 position \n");
else if (bits == 8) printf("64 position \n");
else printf("others, bits = %d\n", bits);
}
边栏推荐
- pom. Brief introduction of XML configuration file label function
- 最多可以参加的会议数目[贪心 + 优先队列]
- 毕业季|遗憾而又幸运的毕业季
- Force buckle 674 Longest continuous increasing sequence
- 【STL】vector
- BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
- Sword finger offer II 013 Sum of two-dimensional submatrix
- 力扣 912.排序数组
- mock.js从对象数组中任选数据返回一个数组
- LeetCode_7_5
猜你喜欢

Compiler optimization (4): inductive variables

MRS离线数据分析:通过Flink作业处理OBS数据

Ways to improve the utilization of openeuler resources 01: Introduction

The boundary of Bi: what is bi not suitable for? Master data, Martech? How to expand?

8 CAS

Chapter 9 Yunji datacanvas company won the highest honor of the "fifth digital finance innovation competition"!

Interpretation of transpose convolution theory (input-output size analysis)

力扣 599. 两个列表的最小索引总和

Implement secondary index with Gaussian redis

Vulnhub's funfox2
随机推荐
Detailed explanation of Flink parallelism and slot
Nunjuks template engine
力扣 1037.有效的回旋镖
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
Equals method
Force buckle 1232 Dotted line
[auto.js] automatic script
The boundary of Bi: what is bi not suitable for? Master data, Martech? How to expand?
841. String hash
8 CAS
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
School 1 of vulnhub
Force buckle 1961 Check whether the string is an array prefix
Oracle 存储过程之遍历
力扣 2315.统计星号
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
剑指 Offer II 013. 二维子矩阵的和
CSDN syntax description
【Auto.js】自动化脚本
开源OA开发平台:合同管理使用手册