【发布时间】:2017-11-09 09:56:27
【问题描述】:
很抱歉这个简单的问题,但我真的不明白如何正确地在 C 上创建 consol。我想要几个将更新的动态行。我知道我可以使用\r,但它只适用于一行。我想要几行。 system("cls") 不适合这个。也许你能帮帮我。
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main() {
int currInt = 0;
while (true) {
system("cls");
printf("%d", currInt);
currInt++;
if (currInt == 5) {
currInt = 0;
}
}
}
我将有异步输入数据,这些数据将显示在几行上,我需要更新此屏幕。我想到了system("cls"),但它并没有清除循环中的屏幕。无限循环很重要。
【问题讨论】:
-
您必须为此使用
curses/ncurses库。仅使用 printf 是不可能的 -
“创建简单的显示”,有趣的标题。显示某些东西可能是 C 语言中最难做的事情。
-
你能给我推荐文章或图书馆吗?