Standard C doesn't care about which OS you're on, so there is no standard way to find out. Not that this is much of a problem, since each OS has a different executable format (not to mention many different processor types), you can't just compile a bit of code and then expect it to execute on any machine.
When you compile the code, you typically have
Code:
#ifdef DOS
/* code specific to DOS here */
#elifdef WIN32
/* code specific to Win32 here */
#elif LINUX
/* code specific to Linux here */
#else
#error Need another OS
#endif
Unfortunately, there is no standard naming convention for those defines.
An alternative is to put all the non-portable code into
porting_dos.c
porting_win32.c
porting_linux.c
In either case, it's a good idea to minimise the amount of code in such places.