#include <stdio.h>
#include <bits/wordsize.h>
int main() {
#if __WORDSIZE==32
printf("The system is 32 bits\n");
#endif
#if __WORDSIZE==64
printf("The system is 64 bits\n");
#endif
return 0;
}
OR
#include <stdio.h>
int main() {
#ifdef __x86_64__
printf("The system is 64 bits\n");
#endif
#ifdef __i386__
printf("The system is 32 bits\n");
#endif
return 0;
}
__x86_64__ and __i386___ is defined by the compiler.