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){
s
To answer your question strictly as given:
#include
#include
#include
#include
int main(void) {
long wordBits = sysconf(_SC_WORD_BIT);
if (wordBits == -1 && errno == EINVAL)
return EXIT_FAILURE;
else
printf("%ld\n", wordBits);
return EXIT_SUCCESS;
}
This would work in any situation where glibc is correctly configured, and would print your register size to stdout, or return an exit code of 1 otherwise.