+ 1

Why are "system" commands looked down upon in C++?

ex: system("pause") system("clr")

6th Nov 2016, 10:34 PM
Paul Birkholtz
Paul Birkholtz - avatar
3 Respostas
+ 2
So I guess it is because your making an OS call and not all OS are the same plus it is a security risk and most antivirus software will have problems with it. Also most system commands are very resource heavy as I read in one article its like opening your front door with a bulldozer.
6th Nov 2016, 10:41 PM
Paul Birkholtz
Paul Birkholtz - avatar
+ 1
Not just C++ :) The main problem is that they are platform-dependent, for example system("clr") won't even work on linux. They also tend to be a bit slow. Also, you have no way of knowing that nobody tampered with the command you are trying to execute. Maybe you are executing malicious code, and you don't even know it!
6th Nov 2016, 10:43 PM
Schindlabua
Schindlabua - avatar
+ 1
Come with window.h file and some of its function work in only windows os. system("pause"); use to pause program but it is slower than getch() function. it stop program for a while until you not send input to console. system("cls"); use to clear program console. It erase all above program buffer or input output statements. use only in windows for UNIX and Linux use system("clear");
6th Nov 2016, 10:45 PM
Aditya kumar pandey
Aditya kumar pandey - avatar