在C和C ++清屏基于UNIX的系统上?

在C和C ++清屏基于UNIX的系统上?

问题描述:

我想知道:如何清洁屏幕基于UNIX的系统上?我在互联网上搜索,但我刚刚找到如何做到这一点在Windows上:系统(CLS)
我不希望确切地cpmpletely清洁屏幕,但我想开一个新的一页,如在纳米和VI编辑器。谢谢

I want to know: how to clean screen on an UNIX-based system? I searched on the Internet, but I've just found how to do it on Windows: system("CLS") I don't want exactly to clean cpmpletely the screen, but I want to open a "new page", such as in the NANO and VI editors. Thanks

您可以使用以下code它们使用的termcap清晰画面。
(不要忘了与库链接)

You can use the following code which use termcap for clear screen. (don't forget to link with the library)

#include <stdio.h>
#include <stdlib.h>
#include <termcap.h>

void clear_screen()
{
char buf[1024];
char *str;

tgetent(buf, getenv("TERM"));
str = tgetstr("cl", NULL);
fputs(str, stdout);
}