C:由$ P $终止程序pssing的关键 [英] C: Terminating the program by pressing a key
本文介绍了C:由$ P $终止程序pssing的关键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C,我通常使用残培()
函数等待一个关键是pressed,然后结束该程序,但最近我读了自从它不是一个标准功能,它的坏的编程习惯使用它。
In C, I normally use the getch()
function to wait for a key to be pressed and then end the program, but recently I read that since it's not a standard function, it's bad programming practice to use it.
所以不是以下内容:
int main() {
dosomething();
getch(); //wait for the user to see the results and press a key to end
return 0;
}
我应该怎么做,以取代残培
?
推荐答案
GETC(标准输入);
是便携式的在这个意义上
getc(stdin);
is portable in this sense
这篇关于C:由$ P $终止程序pssing的关键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文