-
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
-
when system cls dont work, then try clrscr;
that only works with some compilers
-
the clrscr only works with dos based compilers, codeworks is windows based.
-
....
int i;
for (i=0; i < 30; ++i)
cout << '\n';
....
Screen cleared....
-
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?
-
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...
-
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. ;)
-
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.
-
>>for (i = 0 ; i < 30; ++i)
i think 25 will work [80x25 in dos mode]
-
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 :D. Okay I am about to get yelled at by the teacher because he is crazy so, thanks, bye.
-
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=0; i < 30; ++i)
cout << '\n';
cout << '\r';
have fun :)