【问题标题】:Create simple display创建简单的显示
【发布时间】: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 语言中最难做的事情。
  • 你能给我推荐文章或图书馆吗?

标签: c io console


【解决方案1】:

我怀疑printf() 会帮助您实现目标。如果我是你,我会尝试Ncurses。也检查这个问题:Where can I find a complete reference of the ncurses C API?

如果这个库不能满足你,那么我建议curses.h。但是我怀疑这是否可行,因为 Ncurses 是原始诅咒的现代实现。


对于 Windows:Is ncurses available for windows?

【讨论】:

  • windows 呢?
  • 谢谢。我会试试这个库
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-09
  • 2015-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多