C语言中system("pause")是什么作用?

来源:互联网 发布:sql语句中not in 编辑:程序博客网 时间:2024/06/07 09:45
system就是调用从程序中调用系统命令(和shell命令)。   
system("pause")就是从程序里调用“pause”命令;
而“pause”这个系统命令的功能很简单,就是在命令行上输出一行类似于“Press any key to exit”或“请按任意键继续...”的字,等待用户按一个键,然后返回。
【赠送查找数字源代码】
#include <stdio.h>#include <stdlib.h>#include <time.h>#define N 20int main(){int arr[N], x, n, i;int f = -1;srand(time(NULL));for (i=0;i<N;i++){arr[i] = rand() / 1000;}printf("输入要查找的整数:");scanf("%d",&x);for (i = 0; i < N; i++){if (x==arr[i]){f = i;break;}}printf("\n随机生成的数据序列:\n");for (i=0;i<N;i++){printf("%d ",arr[i]);}printf("\n\n");if (f < 0){printf("没找到数据:%d\n",x);}else{printf("数据:%d 位于数组的第%d个元素.\n",x,f+1);}system("pause");return 0;}

【显示结果】