c - 在 c 中加载 bar 而不会弄乱其他输出
问题描述
我需要制作一个像 apt 数据包管理器中的加载栏(图片)
我找到了一个很酷的库来实现这一点,但问题是由于打印了进度条,加载条上方的所有文本(例如在图像中,“处理触发器...”)都没有打印出来。
如何在屏幕上同时打印加载栏和信息?
我的实际代码是这样的:
int main(void){
while ((read = getline(&line, &len, file)) != -1) {
char *newline = strchr(line, '\n');
if (newline)
*newline = 0;
puts("");
currline++;
progressBar(currline, lines);
}
}
void progressBar(size_t count, size_t lines){
progressbar *progress = progressbar_new("Loading",lines); // function provided b the linked library (It initialize the progress bar so takes the name and the number of lines)
for (size_t i = 0; i < lines; i++)
progressbar_inc(progress); // provided by the library (it increments progressbar of a single step and call progressbar_update() that print the value by calling progressbar_draw()
progressbar_finish(progress); // just free all allocated memory and print a newline
}
如果您想更详细地查看引用的函数,请参见此处。
解决方案
推荐阅读
- c# - 如何在 dotnet core 的块 blob 类型存储中的现有文件中附加新的 csv 数据。我试图附加,但它显示错误
- deep-learning - YOLOv4中的损失和mAP图表
- database - “DocumentSnapshot”类型不是“Map”类型的子类型
' - azure-eventhub - 什么是 bob 容器和检查点
- matlab - 直线和绘图之间的阴影区域
- docker - 我正在尝试在 Ubuntu 20.04.2 LTS 上使用 docker 运行球童服务器,但球童没有启动
- javascript - 使用 JS 更改文本内容
- haskell - 使用 QuickCheck monadicIO 时如何防止测试的函数输出到终端
- python - 线程 django-main-thread django 中的异常
- sql-server - 如何连接PHP7.3、sql server & Nginx Debian10