在C语言中system("cls") 怎么用?

来源:百度知道 编辑:UC知道 时间:2024/06/13 23:06:38

#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
for(i =0;i<5;i++)
printf("%d******************\n",i);
getchar();
system("cls");
return 0;
}

其必须包含头文件 #include <stdlib.h>
其作用是清楚屏幕先前的显示内容

在你的主函数里可以直接调用.要以分号结尾.要注意的是,一般要在变量定义之后调用.就这样,朋友.

system()函数包含在stdlib.h里面,例如
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("按Enter清屏");
getchar();
system("cls");
return 0;
}

在c语言中,它的作用是清屏的做用,它的头文件是#include<conio.h>

这个是清屏的函数,可以在显示前调用这个函数,这样就可以清晰的显示了。