I want to clear the screen, but system("cls") doesn't work with windows Xp. Can anyone tell me of a library with a function to clear the screen or another method?
I want to clear the screen, but system("cls") doesn't work with windows Xp. Can anyone tell me of a library with a function to clear the screen or another method?
I think system("clrscr") works for one of the systems but im prolly wrong (newbie)
You might want to check your code again - I am running win xp myself and calling system("cls"); works great...
If you mean in an MSDOS window, I would do it manually. Try this:If that's not what you're looking for, sorry. Also, it may not look real nice, but I am pretty new to C++, and at least it worksCode:cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
I can vouch for the system("cls") command. I have it in one of my programs and it works great on Windows XP.
Use of the system function is another one of those things that will recieve nasty comments on this forum. Basically the problem is that it depends too heavily on external resources that are easily tampered with. Your code won't work on non-Windows systems, and even on Windows systems, it's easy to remove the CLS program.
In this case, it's not such a terrible sin, but keep this in mind.
check in your conio.h file...it's still not very portable......clearing your screen in general isn't really all that 'portable' either....what if someone didn't want their screen cleared when they ran your program? what if another program called your program? it's certainly not nice to erase someone elses hard work
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
oh yea....read the FAQ!
but, while the thread is here, i will take the oppurtunity to ask a related question....
how do programs typically clear the screen the polite way in *nix. for example, vim or nano.
they appearantly erase the whole, but somehow the console retains all the text that it did before it called nano or vim.....my first thought is that they store a "copy" of it and rewrite it on exit....but then i thought, what if vim or nano crashed? (of course, this has never happened )
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
Taken from Alvaro on the cpp-home forums:
It works on most platforms (Windows included).void clrscr(){
std::cout << "\33[2J\33[1;1H" << std::flush;
}
I have a 6 part tutorial on console programming here. Clearing the screen is covered in part 2. If you are doing a lot of console programming, there is a lot of material of potential use there.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.