C语言中清屏函数是什么?

C语言中清屏函数是什么?

C语言中清屏函数是为清除屏幕上的输出功能,用法是:

void clrscr(void);

程序例:

#include <conio.h>

int main ()

{

int i;

clrscr();

for (i = 0; i < 20; i++);

cprintf("%d\r\n", i);

cprintf("\r\nPress any key to clear screen");

getch();

clrscr();

cprintf("The screen has been cleared!");

getch();

return 0;

}

相似的clrscr清屏函数:

clrscr并不是C语言的标准库函数,而是TC平台特有的函数,在其它编译器中无法使用。

1、函数声明:

void clrscr(void);

2、头文件:

#include <conio.h>

3、程序示例:

4、在当前主流编译器中,不支持该函数,可以用

system("cls");//windows平台

system("clear");//unix/Linux平台

实现相同效果。

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-01
用 system("CLS");可以达到清屏的效果,在dos屏中。
system函数已经被收录在标准c库中,通过命令进行系统调用。
函数原型:int system(char *command);
参数: 字符类型的command
功 能: 发出一个DOS命令
实例:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
system("PAUSE");//系统PAUSE
system("CLS");//清屏
system("PAUSE");//系统PAUSE
return 0;
}
第2个回答  2009-04-27
cls
第3个回答  2009-04-27
clrscr();本回答被提问者采纳