Does anyone know how I can clear the screen of my program without just putting a bunch of endl; or \n; ??
Does anyone know how I can clear the screen of my program without just putting a bunch of endl; or \n; ??
Use the code clrscr(); to clear the screen
When I try to use it, I get an error message saying undeclared indentifier on Visiual C++. Do I have to include any header files?
Read the FAQ.
Brendan
Draco dormiens nunquam titallandus.
Console Graphics Library: http://www.geocities.com/steve_alberto/cgl.html
>Does anyone know how I can clear the screen of my program
Why do you need to clear the screen? In my experience, such functionality is almost never needed. Then there's the portability problem as well. I would wager that you want to clear the screen so that you can print a pretty little menu, am I correct?
>without just putting a bunch of endl; or \n; ??
Thats' basically what you end up doing no matter how much abstraction you put around it.
My best code is written with the delete key.
It's part of an assignment. We have to make a version of the Game "Connect Four" and we're asked to clear the screen so that we can redraw the board.
And I bet you still didn't read the FAQ, did you?Originally posted by mannyginda2g
It's part of an assignment. We have to make a version of the Game "Connect Four" and we're asked to clear the screen so that we can redraw the board.
Quzah.
Hope is the first step on the road to disappointment.
I detect a lot of n00b hate here. Calm down before mannyginda lets off one of those n00b tirades. They are all too common at this time of year.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
No need to calm down; it's in the FAQ. Click that. It's a link. To the answer. For your question. Merry Christmas. While you're there, read the rest of the articles.Originally posted by bennyandthejets
I detect a lot of n00b hate here. Calm down before mannyginda lets off one of those n00b tirades. They are all too common at this time of year.
Away.
>It's part of an assignment.
Take the low road and keep it simple.
Code:void clearscr ( void ) { for ( int i = 0; i < 50; i++ ) // 50 is arbitrary cout<<'\n'; cout<<flush; }
My best code is written with the delete key.
header= <stdlib.h> || <cstdlib>
function= system("cls")
however i would also advice you to listen to the guys here theyre
just helping.
>function= system("cls")
slow + nonportable = not recommended
Any program that needs to clear the screen (or thinks it needs to clear the screen) is going to be doing it a lot. Calling speed intensive functions like system frequently is going to slow down the program a great deal. The nonportable part isn't as important since the OP is probably working with Windows exclusively, but it's still a bad habit to get into.
In general I recommend against using system except when it's really necessary, even if the alternative solution is platform or compiler dependent. Of course, the point is moot if the OP actually looks at the FAQ and uses the function defined there.
My best code is written with the delete key.
thanks for the information prelude.
i was just telling him that was a possoble way offcourse there are
alternatives.
Thanks guys, nah I did read the FAQ, it helped. It's all love don't worry about it.
is there a better way than this? (my compiler doesn't have clrscr())Originally posted by Prelude
>It's part of an assignment.
Take the low road and keep it simple.
Code:void clearscr ( void ) { for ( int i = 0; i < 50; i++ ) // 50 is arbitrary cout<<'\n'; cout<<flush; }
and what does flush do?
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT