How can I find out which operating system is used? - I have the same C code for a Windows and Linux computer and need this information during running the code.
there are predefined macros like linux or win32 to find the OS of the system. you can find out the complete list of macros from http://predef.sourceforge.net/preos.html
let me tell you- how to use them. for example you want to clear screen while you are running your code.
in windows, we use system command
>cls
in linux, we use system command
$clear
1 2 3 4 5 6 7 8 9
#ifdef linux
// linux related code goes here
system("clear");
#endif
#ifdef win32
// windows related code goes here
system("cls");
#endif
Yes, alas, there is no runtime function in either C or C++ to tell you what OS is running. The only way is, essentially, a priori knowledge from the compile-time environment. Usually this manifests via macros.