A simple answer to "Why is system() discouraged?"

I do not claim to be anything but a beginner programmer, but I believe that I have stumbled upon an example of how system() can slow down a program.
In an infinite loop, put the statement cout <<"10"; //or whatever you want to print and run it. Include iostream, of course. Notice the speed at which it runs. Now put a system() line right before the cout statement. It now prints out the line at a noticeably slower rate. This, I believe, is because the computer takes some time to execute system(). By itself, system() does not cause too much speed decrease, but in a loop it can make the program far more inefficient. Also, I'm kinda sure that system("some command") arguments are batch commands, and batch does not work properly on OS other than windows. Correct me if I'm wrong though, as I know almost nothing about batch.
http://www.cplusplus.com/forum/articles/11153/

It basically explains all of the points you made and more.
Topic archived. No new replies allowed.