cls isn't portable.
To clear the text in a program, press Ctrl-A and then Del.
http://faq.cprogramming.com/cgi-bin/...&id=1043284385
Lol! Well I think I just heard matsp behind me with a vat of tar and a bag of feathers for telling people to use that particular command.
Its only fair that I explain why some people will tell you not to use system(). The system() simply just calls processes shell commands. So if you say system("pause") it will execute the pause program. Or if you say system("notepad") then notepad will popup (or you could put system("gedit") for all you linux folk).
The reason it is insecure is that it will just execute cls. Not necessarily the cls you want it to execute... just whichever one it finds in the current working directory or path variable. So someone could pull a fast one on you and throw a virus on your computer called "cls" and your program will officially be what starts that virus. 9 times out of 10 you end up with conflicts over malicious code, just FYI.
:S I use cls all the time on my linux box... did I make a link..........
AdampqmabA today you are officially inducted into the hall of "Don't program like that."
You can also jump around like this:
However, I doubt this is going to be useful in C++ code, since it wouldn't call any destructors when leaving the function.Code:#include <iostream> #include <csetjmp> using namespace std; void jumping(); jmp_buf jumper; int main(){ cout << "hello"; cout << "1"; setjmp(jumper); cout << "2"; if (std::cin.get()) { jumping(); } return 0; } void jumping(){ cout << "In jumping\n"; longjmp(jumper, 1); }
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Nice. I can say that I have honestly never found an instance where I was able to produce more optimal code by using jumps. I am not so categorically against others using them. I don't use them very often myself. Its like a star screw-driver. Not a practical tool for most jobs, but when you need it, its a good thing to have handy.
I hope you caught anon's revelation about longjmp(). I didn't know that C supported long jumps. Now I know And knowing is half the battle!