Thread: Clear Console Screen

  1. #1
    Registered User
    Join Date
    Feb 2008

    Clear Console Screen

    Hello guys,

    I'm fully aware I can clear the command line interface with:

    however doesn't this limit my program to Windows only?, if so are they any good techniques to maintain portability.
    Last edited by Cero.Uno; 04-21-2008 at 03:10 PM.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Katy, Texas
    for (i = 0 ; i < some_number_that_you_guess_is_the_number_of_console_lines ; i++) printf("\n") ;
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Apr 2008
    I don't think there is a portable solution, but most terminal emulators support escape sequences:

    e.g. printf("\033[2J\n"); /* vt100, clear screen escape sequence */

    Additional code is needed to move the cursor.
    This work on unix-like systems, don't know with windows.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    Or look in the Frequently Asked Questions:

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Clear Screen Again!!!
    By trang in forum C Programming
    Replies: 3
    Last Post: 12-13-2003, 08:36 AM
  2. Yet another clear screen thread :D
    By kermit in forum Linux Programming
    Replies: 2
    Last Post: 11-20-2003, 05:14 AM
  3. How to clear the screen?
    By Zopyrus in forum C++ Programming
    Replies: 8
    Last Post: 11-07-2003, 10:20 PM
  4. Clear Screen
    By KneeGrow in forum C++ Programming
    Replies: 1
    Last Post: 10-24-2003, 10:17 PM
  5. Console Screen Buffer
    By GaPe in forum Windows Programming
    Replies: 0
    Last Post: 02-06-2003, 05:15 AM