system(“pause”); - Why is it wrong?

前端 未结 13 2364
轻奢々
轻奢々 2020-11-21 07:39

Here\'s a question that I don\'t quite understand:

The command, system(\"pause\"); is taught to new programmers as a way to pause a program and wait for

13条回答
  •  庸人自扰
    2020-11-21 07:51

    Because it is not portable.

    pause
    

    is a windows / dos only program, so this your code won't run on linux. Moreover, system is not generally regarded as a very good way to call another program - it is usually better to use CreateProcess or fork or something similar.

提交回复
热议问题