how to find if the machine is 32bit or 64bit
Posted
by prabodh
on Stack Overflow
See other posts from Stack Overflow
or by prabodh
Published on 2010-03-08T13:58:36Z
Indexed on
2010/03/08
14:06 UTC
Read the original article
Hit count: 609
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.
© Stack Overflow or respective owner