Clear screen command for c++?

Pages: 12
What is the clear screen command for c++?
C++ does not even know what a screen is.
-1 rep modoran

Command is

1
2
3
4
5
6
7
#include <...>
int main()
{
     clrscr();

     // your code
}


You DO NOT need any other special functions. CLRSCR(); is all you need. I assume that you are using Borland C++. If you use any other program such as MinGW, WxDevC++, Code::Blocks... You don't need to clear the screen, as it clears itself after you run the code.
Last edited on
Jumper, it seems clrscr() is a non-standard extension of the C++ language. Truly, C++ doesn't know what a screen is.

Wazzak
Strange... I use it each time I program at school. Our school uses Borland C++...
I guess he has to include some library...
jumper007
Why not read the link posted instead of pretending you are an expert because you know something about an out-of-date compiler system?
Our school uses Borland C++...


Ouch. Well, at least now you know.
I am obligated to use Borland at school. Don't blame me. At home I use only MinGW, wxDevC++ and other programming languages (java, dreamwaver (html/css)). Not my fault that the school doesn't have enough money to buy a good software, ... (and some new pc's >.> the actual ones cannot even run internet properly >.> )
Last edited on
@Duoas

I assumed that NOT ALL who visit this site are ACTUALLY READY FOR CREATING THEIR OWN HEADER FILES. http://www.cplusplus.com/articles/4z18T05o/ is showing how to create the header file for clearing screen. No offence, but IF YOU ARE NOT RUNNING BORLAND, why whould you need clear screen ?

PS: Atleast my MinGW and DevC++ DO NOT KEEP THE SCREEN DATA (it gets auto-clear each time I run it)
Last edited on
Atleast my MinGW and DevC++ DO NOT KEEP THE SCREEN DATA

That's a bad thing.


I assumed that NOT ALL who visit this site are ACTUALLY READY FOR CREATING THEIR OWN HEADER FILES.

A header file and a cpp file are no different. They're both plain text conforming to the C++ standard. You could rename a *.cpp file *.h and it would work exactly the same way. If you're ready to write C++ code, you're reader to write header files.

No offence, but IF YOU ARE NOT RUNNING BORLAND, why whould you need clear screen ?

What does your choice of dev environment have to do with the requirements of a program? If the user wants the screen cleared, the user wants the screen cleared. The user does not care what was used to make the program. The user cares what the program does.
Last edited on
¿Why is it bad to span a new shell?
If you are not running borland, why whould you need clear screen ?
(I can't stand uppercase) Because you use the console to launch your programs, and you want your line of sight on a rest position or want to eliminate some noise.
Still you are propably better using the program clear or cls, but no inside the cpp code, xP.

I hope that you are refering to C++ Builder (2011) instead of Borland C++(1999)
@ Moschops: What jumper007 is seeing is that wxDev-C++ does not open your application inside of a shell that it made like Borland and Code::Blocks do. It allows the shell that the operating system is running to close after your application is finished running, which I personally prefer because it means that my IDE is not likely to cause problems when I go to test a program. Be careful with that bit about .h\.hpp and .cpp files being the same, this is largely dependent on what linker you are using. Generally speaking header files are meant to be included, as in tell the compiler to write the contents of this file here, in line with the rest of the file below, before compiling the rest of this code. While .cpp files are meant to be linked to and compiled as stand alone pieces of the same executable. I'm sorry because I know I'm being pedantic, but for me it's these little things that are the toughest to "unlearn" as I progress. I completley agree with your last statement a dev environment should never dictate to it's user what they can and can't do.

@ jumper007: I know, doesn't it stink when your school can't afford up to date software? I don't know about you but I nearley had to take out a second mortgage to get wxDev-C++, then having to get MingW! It's amazing anyone can afford this hobby! </sarcasm>

Last edited on
@ Computergeek01: I know that my English is not good enough yet to express my ideas right. I mean that the school does not give funds for new PC / SOFTWARE being bought. Buying a PC REQUIRES AN OPERATING SYSTEM which anyone can afford! </sarcasm>*You might need a mortgage for buying like 400x Windows licences!! (I assume that your are not that idiot to think that they can re-use the serials they have at the moment)

PS: I think I am right with the number of 400 PC's (approximately) as our school has 5-6 programming labs.
Last edited on
@Moschops: No
Last edited on
No comment
Last edited on
Jumper, you're starting to get a bit rude. Are you sure you know the difference between a header and a source file aside from the extension?

-Albatross
I don't know the difference. In this tutorial they are talking about prototypes. I don't have any idea what that is! I am sure that not anyone who can do a C++ program can actually do a header file for this purpose.

PS: I will stop it right here. I just say that when I fistly came here I was barely able to do some short and beginner softwares. I think that if someone had given me this answers then, I would certainly had left this forum.
Last edited on
Jumper, you are incorrect. The code you just posted is just code - it has no bearing at all on your argument, and that you post it thinking it somehow supports your position indicates that you don't have even the most basic grasp of what a C++ compiler does.

You can at this point do one of two things; realise your own lack of knowledge and start improving, or lose your temper, throw insults, and continue in ignorance. The choice is yours.
Duoas's snippets are actually very easy to integrate into a single-file project. All you have to do is copy and paste the snippets to the top of your main file. He didn't spend much time on explaining how to do that because I assume he assumed that most people knew how.

All the above examples are snippets, which you should know how to properly integrate into your program. For simple stuff, it is enough to just copy and paste the code into your program somewhere before it is used.


-Albatross
Pages: 12