[Original] C ++ determines whether the operating system is 16-bit or 32-bit

Source: Internet
Author: User

There are two solutions:

1. whether the operating system is 16-bit or 32-bit is related to its address addressing method (CPU support is required, but it is not necessarily related to the CPU length). Therefore, you can directly use the pointer (address) to judge:

Cout <(sizeof (int *) = 4? "32 bit": "16 bit") <Endl;

2. If sizeof is not allowed, it is determined by the range indicated by an integer. The maximum integer value in a 16-bit system is 65535:

Unsigned int A = ~ 0;
Cout <(A> 65535? "32 bit": "16 bit") <Endl;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.