An old question: how to use the C ++ program to view the number of bits in the operating system (16 or 32 bits)

Source: Internet
Author: User

I am bored with the skill assessment conducted by the company today! There is actually a problem that can be called antique: How to Use the C ++ program to view the number of digits of the Operating System (16-or 32-bit), not the sizeof () function

This problem itself seems to be a very complicated problem. I personally think it should be a very profound problem for the program to view the number of digits in the operating system, there should be corresponding API functions in windows. I don't know how compilers of different versions handle this problem.

Source code on my questions:

# Include <iostream>
# Include <iomanip>
Using namespace STD;
Int main (void)
{
Unsigned int A = 1;
A = ~ A;
Cout Int COUNT = 0;
While ()
{
A = A/2;
Count ++;
}
If (count> 16)
{
Cout <"32 bits OS" <Endl;
}
Else
{
Cout <"16 bits OS" <Endl;
}

Return 0;
}

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.