3 Replies - 2402 Views - Last Post: 16 September 2011 - 09:21 PM Rate Topic: -----

#1 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,155
  • Joined: 10-May 07

Determine OS

Posted 20 February 2008 - 11:30 PM

Description: Use pre-processor defines to use the code correct for the OS that the code is compiled on.
#include <stdio.h>

int main(void) {

  #ifdef WINDOWS
    system("CLS");
  #elif defined(WIN32)
    system("CLS");
  #elif defined(linux)
    system("clear");
  #elif defined(CYGWIN32)
    system("clear");
  #endif

  printf("Screen should be blank...n");

  return 0;
}


Is This A Good Question/Topic? 0
  • +

Replies To: Determine OS

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,155
  • Joined: 10-May 07

Re: Determine OS

Posted 20 February 2008 - 11:30 PM

Description: Use pre-processor defines to use the code correct for the OS that the code is compiled on.
#include <stdio.h>

/*
  Written for Dream In Code 02/21/2008
  by -#2pencil-
*/

int main(void) {

  #ifdef WINDOWS
    system("CLS");
  #elif defined(WIN32)
    system("CLS");
  #elif defined(linux)
    system("clear");
  #elif defined(CYGWIN32)
    system("clear");
  #endif

  printf("Screen should be blank...n");

  return 0;
}

Was This Post Helpful? 0
  • +
  • -

#3 athlon32   User is offline

  • D.I.C Regular
  • member icon

Reputation: 117
  • View blog
  • Posts: 363
  • Joined: 20-August 08

Re: Determine OS

Posted 20 January 2010 - 10:15 PM

1. this taught me how to clear my screen in windows 2. that's cool :D
Was This Post Helpful? 0
  • +
  • -

#4 hulla   User is offline

  • Writing Lines


Reputation: 49
  • View blog
  • Posts: 733
  • Joined: 05-March 11

Re: Determine OS

Posted 24 July 2011 - 02:01 AM

Cool
Was This Post Helpful? 0
  • +
  • -

#5 basil2style   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 16-September 11

Re: Determine OS

Posted 16 September 2011 - 09:21 PM

nice 1.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1