免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 12506 | 回复: 4
打印 上一主题 下一主题

一句话实现linux终端清屏(帮忙解释一下这句C语言) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-09-12 23:44 |只看该作者 |倒序浏览
10可用积分
printf("%s",   "\033[1H\033[2J");


/*file:   clear.c
*compile:   gcc -o clear clear.c
*use:   ./clear
*/
#include <stdio.h>

int main()
{
       printf("%s",   "\033[1H\033[2J");
       return 0;
}


但是我不太明白"\033[1H\033[2J"的意思,如果谁知道,请给我解释一下,本人感恩不尽

最佳答案

查看完整内容

这个是 ANSI/VT100 Terminal Control Escape Sequences,见 http://www.termsys.demon.co.uk/vtansi.htm

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
2 [报告]
发表于 2008-09-12 23:44 |只看该作者
这个是  ANSI/VT100 Terminal Control Escape Sequences,见 http://www.termsys.demon.co.uk/vtansi.htm

论坛徽章:
0
3 [报告]
发表于 2008-09-13 01:20 |只看该作者
谢谢
Move to Position         ESC[row;colH         Move the cursor to the (col, row) position. Note that the row comes before column; that is, y comes before x. Either col or row can be omitted. Row and column both start with "1," not zero. (1, 1) corresponds to the top-left corner of the screen.

Clear Screen         ESC[2J         Clear the whole screen and position the cursor to the top left corner.


"\033[1H\033[2J"相当于ESC[1H  ESC[2J,就是说把光标移到左上角,然后清屏

论坛徽章:
1
天秤座
日期:2013-10-23 13:20:42
4 [报告]
发表于 2008-09-15 20:15 |只看该作者
#include <stdio.h>
int main()
{
       printf("%s",   "\033[2J");
       return 0;
}

就这样行不!?  ESC[2J 已经包含这个 \033[1H 的作用了吧!

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
5 [报告]
发表于 2008-09-17 09:25 |只看该作者
末有这么复杂的。


  1. puts("\033[2J");
复制代码


OK! 了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP