How to find which operating system is running the PC in C++?
Well, C++ is a compiled language, meaning that a particular operating system is always targeted when compiling the code, i.e., the operating system type is known at compile-time. And all compilers will define a number of predefined MACROs that will identify (fairly completely) what the target system is. Here is an example of using that:
// this is a Windows environment!
// this is a Linux environment! (any GNU/Linux distribution)
// this is a Mac OSX environment!
// this is a BSD environment! (OpenBSD, FreeBSD, etc.)
// this is a QNX environment!
You can find a comprehensive list of predefined macros here.