So you know how you can clear your screen using system("cls") right but what could you use instead of that because people are telling me system() is evil. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

So you know how you can clear your screen using system("cls") right but what could you use instead of that because people are telling me system() is evil.

1st Aug 2016, 1:07 AM
Tristan Peters
Tristan Peters - avatar
5 Answers
+ 1
I dont know what they mean by evil but it might be just that you need to remember to add the library stdlib.h which contains this "system" command
1st Aug 2016, 1:27 PM
Vlad Cranga
Vlad Cranga - avatar
+ 1
The problem is, using system will make your code platform dependent. Cls will work for clearing a dos terminal. It won't work on Linux based system.
1st Aug 2016, 4:27 PM
Nick D.
Nick D. - avatar
+ 1
@Tristan Peters, No, it's not okay to use it. I want to add to the above reason which will justify why it is not. Using system function may expose your program to vulnerabilities. Depending on the access, the attacker may intercept and change the command instead of the one which you intend to run. Now let's say your program is running at the highest possible privilege(or root). Any program you invoke will just run since you've all the privileges. Now an attacker may just change the command and put his command to invoke a malware. This is a very basic example. There are more complex things which can be done.
2nd Aug 2016, 4:49 PM
Nick D.
Nick D. - avatar
0
Nick D. so it is ok if I use it in any program I make because I'm on windows.
1st Aug 2016, 4:31 PM
Tristan Peters
Tristan Peters - avatar
0
use clrscr() method including the conio.h directory.
1st Aug 2016, 5:57 PM
Shubhranil Chakraborty
Shubhranil Chakraborty - avatar