title: How can I know what OS I'm working in?
body: <p>I need a function that can clear the screen in both Linux and Windows. To do this, I want to know if there are some instructions that can tell me what operating system I'm working with.
  I have searched for solution and I found the following code:</p>
  
  <pre><code>void clear_screen()
  {
     #ifdef WINDOWS
  
      std::system ( "CLS" );
  
      #else
  
      // Assume POSIX
  
      std::system("clear");
  
      #endif
  }
  </code></pre>
  
  <p>There are two problems with this function:</p>
  
  <ul>
  <li><p>I don't understand it.</p>
  
  <p>-> for <code>#ifdef WINDOWS</code>, where is WINDOWS defined?</p></li>
  <li><p>This code works in Linux but it doesn't work in Windows.</p></li>
  </ul>
  
  <p><em>Note :</em></p>
  
  <ul>
  <li><p>I'm using Windows XP.</p></li>
  <li><p>I don't want any non-standard functionality ... such "curses"</p></li>
  </ul>