Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 648857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:52:42+00:00 2026-05-13T21:52:42+00:00

Is there anyway from a C prog to find whether the OS is currently

  • 0

Is there anyway from a C prog to find whether the OS is currently running in 32bit or 64bit mode. I am using a simple program as below

int main(void){
     switch(sizeof(void*)){
        case 4: printf("32\n");
        break;
        case 8: printf("64\n");
        break;
    }
}

Is this a correct approach ?
Would this code work in all the scenarios like, If the hardware is 64bit and the OS is 32bit what would it return ? I don’t have machine to test this in diff configurations.

Thanks for the advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:52:43+00:00Added an answer on May 13, 2026 at 9:52 pm
    • In general, a 32 bits executable won’t be able to tell if it is running under a 64 bit OS or a 32 bit one (some OS could have a way to tell, I know of none but I haven’t searched), a 64 bit executable won’t run under a 32 bit OS (if you discount the possibility for the 32 bits OS to emulate a processor running a 64 bits OS…)

    • sizeof() result is mainly a compile time constant, it won’t returns something different depending on the OS version it is running under.

    What do you want to know really?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway to do insmod and rmmod from C/C++ code? Other than running
Is there anyway easier than this to strip HTML from a string using Perl?
Is there anyway to get a FieldInfo from a field without using something like
Is there anyway to request address from google maps using latitude and longitude? I
Is there anyway to prevent people from using Reflector.net to decompile my .exe c#
I am using navigateToURL for file downloading from server. Is there anyway possible to
Is there anyway to trigger (from VBA) excel asking it to reevaluate ALL its
Is there anyway to create an ObjectSet from a DbSet ? Some background information:
Is there anyway to open the twitter app from an html link on an
Is there anyway to apply this method from Chris Coyier to mobile phones: http://css-tricks.com/full-browser-width-bars/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.