I'm trying to determine, whether the OS is 32bit or 64bit without using predefined functions or system call. I have created following program.
#include <stdio.h>
int main()
{
int i = 1;
int c = 0;
while(i)
{
i = i << 1;
c++;
}
printf("%d\n", c);
if (c == 32)
printf("OS is 32bit\n");
else if (c == 64)
printf("OS is 64bit\n");
else printf("wrong answer\n");
}
In 32bit os gives corret output, but in 64bit os also print "OS is 32bit". So, I found the reason behind that, In 32bit and 64bit OS natarally size of int
4bytes. So, Is there any way to determine whether the OS is 32bit or 64bit without using predefined functions or system calls?