
1、在运行C程序时,还没有来的及看到结果程序就执行完了,因为那可是计算机的速度。
2、好多朋友选择在main函数尾部再加一条语句(如getch())来使程序暂停。
3、其实在C语言里是有专门用于暂停C程序的语句的。
4、system("pause")语句在stdlib.h头文件中,可以在任意时刻真正的暂停程序。
5、具体是这样 *** 作的,我只写代码于此。
6、运行效果是这样。真正的暂停
程序暂停:在C++里使用
#include <conio.h>
getch()
或者
#include <cstdio>
getchar()
在windows中,还可以使用
#include <cstdlib>
system("pause")
如果单纯想要查看结果,还可以使用sleep
windows中
#include <windows>
Sleep(int)
在linux中
#include <unistd.h>
sleep(int)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)