很抱歉这个简单的问题,但我真的不明白如何在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")
,但不清楚循环中的屏幕。无限循环很重要。
答案 0 :(得分:1)
我怀疑printf()
会帮助你实现目标。如果我是你,我会用Ncurses拍摄。也请检查此问题:Where can I find a complete reference of the ncurses C API?
如果这个图书馆不能满足你,那么我会建议curses.h。但是我怀疑这样做,因为Ncurses是原始诅咒的现代实现。
对于Windows:Is ncurses available for windows?