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

前端 未结 13 2073
轻奢々
轻奢々 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:56

    • slow: it has to jump through lots of unnecessary Windows code and a separate program for a simple operation
    • not portable: dependent on the pause program
    • not good style: making a System call should only be done when really necessary
    • more typing: System("pause") is longer than getchar()

    a simple getchar() should do just fine.

提交回复
热议问题