在C和C ++清屏基于UNIX的系统上? [英] Clear screen in C and C++ on UNIX-based system?

查看:187
本文介绍了在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);
} 

这篇关于在C和C ++清屏基于UNIX的系统上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆