Thread: the dreaded CLEAR SCREEN function...

  1. #1
    back? dbaryl's Avatar
    Join Date
    Oct 2001
    Posts
    597

    the dreaded CLEAR SCREEN function...

    OK, just don't kill me for this... I just looked at the FAQ board, and someone suggests to use
    Code:
    #include <stdlib.h> 
    
    system ("cls");
    for clear screen... however, below there's a post that says:

    adrianxw wrote:
    >>> system ("cls");

    Then read the FAQ to find out why this is a bad idea.
    I read the Board FAQ to find why thats wrong, but it isn't there... In fact, the system ("cls"); isn't on the BoardFAQ at all...

    This is my signature. Remind me to change it.

  2. #2
    I thought there was a system("cls"); example in the FAQ too, until i looked (and i compiled the bloody thing). Apparently adrianxw was reffering to the comments about the use of system in the Running Execs segment of the FAQ. The fact of the matter is, system() isnt really something your ever likely to need. It loads up your command processor and it, in turn, executes the argument you passed to system(). Its slow. Veeery slow. Besides... Theres always another way. ... ... *ahem* Couldn't resist.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    79
    1)system("cls") is a very platform dependent way to do it. It will only work on MS-DOS.

    2)It's slow as hell

    As a practical matter, you could use numerous \n's(platform independent) or simply use the clrscr() function in conio.h (which is almost as platform specific as system("cls"))
    All generalizations are false

  4. #4
    >>you could use numerous \n's(platform independent)

    How is that platform dependant? All you have to do is ensure that you have enough \n's to get past any screen that you may encounter. Not too platform dependant.
    What will people say if they hear that I'm a Jesus freak?
    What will people do if they find that it's true?
    I don't really care if they label me a Jesus freak, there is no disguising the truth!

    Jesus Freak, D.C. Talk

    -gnu-ehacks

  5. #5
    back? dbaryl's Avatar
    Join Date
    Oct 2001
    Posts
    597
    >>clrscr() function in conio.h

    I just tried that, but it doesn't work for M$ VC++.... I'm assuming that you just put the #define <conio.h> up on top and clrscr(); inside the main, right?

    If that really doesn't work, what is the BEST way of getting the clear_screen then? (for Visual C++ compiler).

    Thanks
    This is my signature. Remind me to change it.

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    21
    no man. your having a syntax error. u go:

    #include <conio.h>
    #include <iostrem.h>
    #include <stdlib.h>
    #include <stdio.h>
    .
    .
    .

    main(){
    int variable_1;
    char what_ever;

    cout<<"hello";

    whatever....

    clrscr();


    }


    hope u got it....

  7. #7
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    but clrscr() isn't ANSI, so I guess that the only clean way to clear the screen is doing 50 printf("\n");'s

    Oskilian

  8. #8
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    get to the b800:0000 and free your Soul!!! [and, for you non text more graphical tech visionaries, Linear Frame Buffer to the resque!!!!]
    hasafraggin shizigishin oppashigger...

  9. #9
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    The windows way to clear a console window is to write your own ClrScrn function and use that. How to ? Well, read the FAQ.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  10. #10
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>>
    adrianxw wrote:
    >>> system ("cls");

    Then read the FAQ to find out why this is a bad idea.
    <<<

    As someone has pointed out, it was the use of the system() function I was commenting on. There are ways to clear the screen in the FAQ, (I have absolutely no idea I have typed that short phrase!).

    http://www.cprogramming.com/boardfaq.html#execs
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Clear Screen Function?
    By Punkture in forum C Programming
    Replies: 3
    Last Post: 05-05-2003, 09:25 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM