|
-
Dec 20th, 2000, 06:37 AM
#1
Thread Starter
Hyperactive Member
How can I clear the text of a console window?
WP
-
Dec 20th, 2000, 07:16 AM
#2
Frenzied Member
If you're using Borland you can use the clrscr() function, otherwise you could print however many newlines as there are lines on the screen. I don't remember how many that is.
Harry.
"From one thing, know ten thousand things."
-
Dec 21st, 2000, 05:54 AM
#3
Thread Starter
Hyperactive Member
Using C++
I'm using C++, so clrscr() doesn't exist.
What you said about inserting a lot of empty strings, does clear the screen, but then when I insert normal text again, it comes at the bottom of the console, and not at the top.
Any other suggestions?
WP
-
Dec 22nd, 2000, 07:36 PM
#4
Fanatic Member
Try this, put this in your iostream.h file:
#if defined(BORLAND_C)
#include <conio.h>
#define cls() clrscr()
#endif
#if !defined(BORLAND_C)
#include <stdlib.h>
#define cls() system("cls");
#endif
Then whenever you want to clear it, just do cls().
-
Dec 22nd, 2000, 07:44 PM
#5
Monday Morning Lunatic
It's never a good idea to alter the system headers. Put it into a header file of your own if you need to use it. Also, this is slightly more elegant:
Code:
#include <conio.h>
#include <stdlib.h>
#if defined(BORLAND_C)
#define cls() clrscr()
#elseif
#define cls() system("cls");
#endif
If the files are included unnecessarily it won't make any difference because anything that's not used will be removed by any optimising compiler anyway.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|