Originally Posted by
Some Penguin
That said, you shouldn't be using system() that way, since it's expensive (takes two processes -- shell and clear) and is not very robust. Use something like ncurses instead.
Let's generalize that to the following Law:
Code:
Whenever you feel the need to interact with some external application using system(),
1. First research whether a library can do the same.
2. If there's none, use popen().
3. If popen() isn't possible, use system() or implement it yourself.
Use system() as a very last resort. It's better to have your program "inherit" the desired functionality from a library, so that it becomes "its own" and doesn't have to call another shell that you just don't control at all. popen() at least creates a new process to which you can feed input and from you can get output on demand... but not all programs use pipes.
Bookmarks