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
I think your solution is probably valid in most common cases; certainly in all standard IA64 data models pointers are 64bit. This may not however be true of all architectures in theory. It may be safer to test sizeof(uintptr_t) if the compiler has the C99 header; but again it assumes that address width is indicative of register width; it depends whether by "64bit" you are referring to address range or integer range - they need not be the same.
Since 32bit and 64bit compilation requires either a different compiler or a different compiler switch, the target architecture must be known at build-time, and need not be determined at run-time.
Most compilers provide built-in architecture macros to allow this to be determined at build time. A comprehensive list of such macros for a variety of compilers, OS's and architectures is defined at: http://predef.sourceforge.net/