C语言TC中暂停程序运行

两种方法:

1.使用getch()函数。
说明:
char getch(void)
参数:无。
返回值:字符。
作用:从键盘取一字符,但不显示在屏幕上。
使用:
#include <stdio.h>
#include <conio.h> /* 必须的 */

int main()
{
printf("\tpress any key to quit...");
getch();
return 0;
}

2.system("Pause")
system("Pause")表示直接调用DOS命令Pause。
说明:
void system(char *cmd);
参数cmd,DOS命令,如Pause, cls
返回值:无。
使用:
#include <stdio.h>

int main()
{
system("Pause");
return 0;
}

Leave a comment