clrscr函数为C语言的清屏函数,功能为清除屏幕上的输出,clrscr为clear screen的简写。
clrscr并不是C语言的标准库函数,而是TC平台特有的函数,在其它编译器中无法使用。
1 函数声明:
void clrscr(void);
2 头文件:
include [conio.h](https://www.baidu.com/s?wd=conio.h&tn=SE_PcZhidaonwhc_ngpagmjz&rsv_dl=gh_pc_zhidao)
3 程序示例:
| 1 2 3 4 5 6 7 8 9 10 |
#include <conio.h>int main (){cprintf("\r\nPress any key to clear screen");//输出一些文字。getch();//暂停,直到有按键。clrscr();//清除屏幕,之前的输出会被清空。cprintf("The screen has been cleared!");getch();return 0;} |
|---|---|
4 在当前主流编译器中,不支持该函数,可以用
system(“cls”)&tn=SE_PcZhidaonwhc_ngpagmjz&rsv_dl=gh_pc_zhidao);//windows平台
或
system(“clear”);//unix/Linux平台
实现相同效果。
