当前位置:网站首页>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);
}
边栏推荐
- CUDA versions are inconsistent, and errors are reported when compiling apex
- LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
- Traversée des procédures stockées Oracle
- Force buckle 1961 Check whether the string is an array prefix
- Force buckle 674 Longest continuous increasing sequence
- Version selection of boot and cloud
- 最多可以参加的会议数目[贪心 + 优先队列]
- JVM GC垃圾回收简述
- Some important knowledge of MySQL
- Chapter 9 Yunji datacanvas company won the highest honor of the "fifth digital finance innovation competition"!
猜你喜欢
随机推荐
浅尝不辄止系列之试试腾讯云的TUIRoom(晚上有约,未完待续...)
Kubernetes——kubectl命令行工具用法详解
Force buckle 459 Duplicate substring
Force buckle 989 Integer addition in array form
一键部署Redis任意版本
【STL】vector
How to cooperate among multiple threads
Vulnhub tre1
力扣 88.合并两个有序数组
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
多个线程之间如何协同
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
vulnhub之tre1
Training IX basic configuration of network services
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Simulate the implementation of string class
CIS芯片测试到底怎么测?
毕业季|遗憾而又幸运的毕业季
MIT science and technology review article: AgI hype around Gato and other models may make people ignore the really important issues
论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》