Detecting the OS

This is a discussion on Detecting the OS within the C++ Programming forums, part of the General Programming Boards category; Hey all.
I've just been scouting through the board to try and find a solution to what I thought would ...

Detecting the OS

Hey all.

I've just been scouting through the board to try and find a solution to what I thought would be a common problem, but 72 threads later and the only thing close to it, was detecting the Windows version, of which someone suggested using GetVersionEx().

Anyway, I'd just like to determine the platform type, whether it's win32, Linux, BSD etc. Not real important, but I've got a simple program I've made here which uses system("cls") to clear the screen in DOS. However, I'd like to have a go at being able to clear the screen across several platforms (using preprocessor directives I'd imagine).

Would it be possible to do this at all? I've seen the methods of clearing the screen in the FAQ, but I wanted to try something like: