Thread: Clearing Screen

  1. #1
    Registered User NewbieVB's Avatar
    Join Date
    Apr 2002
    Posts
    41

    Angry Clearing Screen

    I use Metrowerks Codewarrior 7 as my compiler and don't know how to clear the screen (LOL). I don't know if it is my compiler or just...well whatever. Could some of you pros, gurus, and junkies help me? The command I have been using is:

    system("CLS");

    along with the #include <stdlib.h> header
    Compiler: Metrowerks Codewarrior 7
    --- I may be a newbie but theres no need to make fun ---

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    30
    when system cls dont work, then try clrscr;

    that only works with some compilers
    HOw are ya?

  3. #3
    Registered User xlnk's Avatar
    Join Date
    Mar 2002
    Posts
    186
    the clrscr only works with dos based compilers, codeworks is windows based.
    the best things in life are simple.

  4. #4
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    ....

    int i;

    for (i=0; i < 30; ++i)
    cout << '\n';

    ....


    Screen cleared....
    Blue

  5. #5
    Registered User NewbieVB's Avatar
    Join Date
    Apr 2002
    Posts
    41
    I am so bad at C++ I can't even read that and understand it...I don't want to type it in and run it unless i get clearance by one other programmer. So could an experienced program just verify that that is true?
    Compiler: Metrowerks Codewarrior 7
    --- I may be a newbie but theres no need to make fun ---

  6. #6
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    int i; //creates a variable to place integers into

    for (i = 0 ; i < 30; ++i)

    // for is a loop (for some value, while condition exists, increment
    // i = 0 means make i equal 0
    // i < 30 is the condition
    // ++i means add one to i or as it is called "increment"
    // this loop runs 30 times

    cout << '\n'; // means put a newline (or return)

    therefore....

    it means, hit return 30 times (0 thru 29). This makes your text leave the screen.... the screen is clear.

    The end...
    Last edited by Betazep; 04-11-2002 at 09:12 PM.
    Blue

  7. #7
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    Oh... and a word of advice. The people on this board with many posts can most generally be trusted to not screw up your computer.
    Blue

  8. #8
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Read the FAQ first. Then, based on this knowledge, ask a question. Your particular question has been answered there already. If you don't understand the answer, come here and ask.
    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.

  9. #9
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    >>for (i = 0 ; i < 30; ++i)

    i think 25 will work [80x25 in dos mode]
    -

  10. #10
    Registered User NewbieVB's Avatar
    Join Date
    Apr 2002
    Posts
    41

    Lightbulb

    OH! Now I see! I am so dumb sometimes I should have understood that anyways thanks for showing me how to clear the screen that way... It really works . Okay I am about to get yelled at by the teacher because he is crazy so, thanks, bye.

  11. #11
    His posts are far and few Esparno's Avatar
    Join Date
    Mar 2002
    Posts
    100
    Wait wait wait! They forgot an important thing! returning the cursor to the top left hand corner! Here is the fully optimised code:

    PHP Code:
    int i

    for (
    i=030; ++i
            
    cout << '\n';
    cout << '\r'
    have fun
    Signature is optional, I didnt opt for one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 04:56 PM
  2. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM
  3. clearing the screen
    By ssharish in forum C Programming
    Replies: 2
    Last Post: 02-01-2005, 09:00 PM
  4. 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
  5. Clearing the screen
    By Shadow in forum C Programming
    Replies: 4
    Last Post: 05-23-2002, 01:40 PM