将屏幕点重置到Windows和Windows的屏幕顶部。 Linux控制台 [英] Reset screen point to the top of screen in Windows & Linux console

查看:206
本文介绍了将屏幕点重置到Windows和Windows的屏幕顶部。 Linux控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Linux和Windows下运行的小程序,用C编写,并在控制台上显示输出。

I have a little routine that's run under Linux and Windows written in C and displays output on the console. I'm not linking in any form of curses or anything like that.

目前我使用

#ifdef __WIN32
  system( "cls" );
#else
  system( "clear" );
#endif

然后我有一堆printf语句来更新状态。我想把屏幕指针重置为0,0,这样我就可以覆盖我的printfs。我想避免编译在任何更多的扩展,特别是因为我编码的2个不同的操作系统。

Then I have a bunch of printf statements to update the status. What I'd like just reset the screenpointer to 0,0 so I can then just overlay my printfs. I'd rather avoid compiling in any more extensions especially since I'm coding for 2 different OS'.

推荐答案

可能找到了一个窗口特定的方式做它 SetConsoleCursorPosition

Looks like I may have found a windows specific way of doing it SetConsoleCursorPosition

Ansi转义序列\033 [0; 0H对于Linux - 只是printf到控制台。

Ansi escape sequence \033[0;0H for Linux - just printf that to the console.

这篇关于将屏幕点重置到Windows和Windows的屏幕顶部。 Linux控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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