Thread: Clear the Screen...

  1. #1
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859

    Clear the Screen...

    I dont know how... Help...

    G++ 2.96.
    Yoshi

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    52
    I've always typed 'clear' at the command line. Hope this is the answer that you're looking for.
    MS VC++ 6.0

  3. #3
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    In stdlib.h there is a function called system() which allows you to pass arguments to the shell. You use this injunction with the clear command for Bash like so:

    Code:
    system("clear");
    Works the same for Windows Console only you use the cls command rather than clear.

    Good luck

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    52
    I usually use a preprocessor macro to save keystrokes later on....
    i.e.
    Code:
    #define CLEAR system("clear") //you can name clear anything, but it's usually good advice to with the actual system name.
    MS VC++ 6.0

  5. #5
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    howdy,
    system() calls are platform dependent and will cause great stress if you try to cross platforms with your code.

    in console use a loop

    void clrscrn()
    {
    for(int i = 0; i < 100; i++)
    cout<<"\n";
    }

    it's a little messy but it will clear the screen and it is platform independent.

    M.R.
    I don't like you very much. Please post a lot less.
    Cheez
    *and then*
    No, I know you were joking. My point still stands.

  6. #6
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    from the faq:
    Code:
    #include <curses.h>
    
    void clrscr()
    {
    static int init;
        if (init == 0)
        {
            initscr();
            init = 1;
        }
        clear();
        refresh();
    }
    'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition

  7. #7
    Registered User
    Join Date
    Sep 2001
    Location
    Fiji
    Posts
    212
    works in linux only though.

    #define clear printf("\033[2J\033[0;0f");

  8. #8
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Originally posted by kwigibo
    works in linux only though.

    #define clear printf("\033[2J\033[0;0f");
    Works on any Terminal which supports vt100

  9. #9
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    >#define clear printf("\033[2J\033[0;0f");

    nifty, how does it work?
    'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition

  10. #10
    Registered User
    Join Date
    Sep 2001
    Location
    Fiji
    Posts
    212
    shaik786, wasn't aware of that fact. I know that they are "ANSI Escape Sequences", and I tried them in windows nt4, and didn't work so I assumed they only worked onl *nix systems (which supports vt100).

  11. #11
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    howdy,
    works pretty damn good in Linux.

    M.R.
    I don't like you very much. Please post a lot less.
    Cheez
    *and then*
    No, I know you were joking. My point still stands.

  12. #12
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Originally posted by kwigibo
    shaik786, wasn't aware of that fact. I know that they are "ANSI Escape Sequences", and I tried them in windows nt4, and didn't work so I assumed they only worked onl *nix systems (which supports vt100).
    Which fact??? :-/

  13. #13
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by shaik786


    Which fact??? :-/
    You've only posted one previous message on this thread... can't be too hard to guess which one kwigibo is talking about!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CLear Screen Routine
    By AQWst in forum C++ Programming
    Replies: 4
    Last Post: 12-13-2004, 08:24 PM
  2. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  3. Getting a clear screen...
    By Finchie_88 in forum C++ Programming
    Replies: 13
    Last Post: 09-03-2004, 05:38 PM
  4. Clear Screen Again!!!
    By trang in forum C Programming
    Replies: 3
    Last Post: 12-13-2003, 08:36 AM
  5. Yet another clear screen thread :D
    By kermit in forum Linux Programming
    Replies: 2
    Last Post: 11-20-2003, 05:14 AM