I'm trying to find a simple, cross platform way to clear the DOS screen. It doesn't really have to be fancy. I'm doing something for fun that a TA at my college said he'd give us candy for. The issue is, I'm writing the code using Dev-Cpp on Windows and he's reading and compiling the code on a Mac.
This is an entry level class and, as this is not an official project, just something for fun, the overall quality of how I get the clearing done doesn't matter. The project is supposed to test our switch-case statement knowledge, so the only thing this is really for is to make my project look a little nicer.
Printing a bunch of new lines seems like the best thing for my case. Since this isn't anything big scale, or even graded, putting a whole lot of effort into clearing the screen wouldn't really do much good.
But looking at that thread, I could probably use some of that in platform specific projects that spring up later.
heck since you are supposed to be doing cross platform and using switches
just do
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
char v;
#ifdef windows //I forget what the actual preprocessor directive is
v = 'w';
#endif
#ifdef unix //likewise I don't even know if this is valid, but something similar to this probably is
v = 'u';
#endif
switch(v)
{
case'w':
system("cls");
break;
case'u': whatevercommandisusedtocleartheunixconsole(); break;
default: cout << "Please use an operating system then restart.\n" << endl; exit(99); break;
}
@firedraco: 1. no one likes "how you word things techinally" Nazis... that being said, nice one, touche ;) and 2. i meant in 4 "commands" ended by semicolons
there, is that better?
oh and same goes for you as well
even if somehow you were to install a virus 'cls' on his computer, saying that system(" ") is insecure is a mute point because had you had access to his computer in the first place you could have gone ahead and ran the virus and not have to wait for someone to write a program that incorporated the use of system("cls"); to launch it.
Actually, getting someone to download a program is quite easy...getting them to run it is the hard part.
Go ahead and use system(), I just wouldn't want to work with you since it makes you seem like you are the same kind of guy of just puts everything in main because they understand it at the time.
system(" "); is insecure. What if you give the code to someone else, and they have the virus but it hasn't been activated? There are a lot of variables, but something that can be easily manipulated such as system(" "); should be avoided unless you're just messing around with the little stuff at home.
it makes you seem like you are the same kind of guy of just puts everything in main because they understand it at the time.
Actually I'm not like that. I highly functionalize. Maybe not as much as some, but i'm more the type to not bother commenting because I understand it at the time.
Look, all im saying is: if you're making a console program, might as well use cls. if you're making a WinAPI program all you so is SetItemText ("") and that will solve your problem