是否可以清除 C 中的多行并保留其他行。
代码:
Displaysenrsordata
loop
printf("This info stays"); <-stay on screen
printf("This info stays"); <-stay on screen
printf("This info Refreshes"); <-update redraw
printf("This info Refreshes"); <-update redraw
printf("This info Refreshes"); <-update redraw
基本上我想让一些文本留在同一个地方并重新绘制更新数据而不清除整个屏幕。
最佳答案
如果你在 linux 上工作,那么使用 ncurses .
例子:
#include <stdio.h>
#include <ncurses.h>
int main (void)
{
int a = 0;
initscr ();
printw("This info stays \n");
printw("This info stays\n");
curs_set (0);
while (a < 100) {
mvprintw (3, 4, "%d", a++);
mvprintw (3, 8, "%d", a++);
mvprintw (3, 12, "%d", a++);
refresh ();
sleep (1);
}
endwin();
return 0;
}
关于清除多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20594082/