终端进度指示器 [英] terminal progress indicator

查看:104
本文介绍了终端进度指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能举例说明如何使用标准库cerr或cout在C ++中编写进度指示器

吗?


我的问题是我不知道如何将输出流重置到

行的开头,所以只需要那些信息就行了。


谢谢 - Koen

解决方案

我不认为c ++有这样的东西。你可以使用

一个回车符号(13)(没有换行符)或者使用退格符号

char(8)以退回到你的方式回到结尾该行(退格键没有

从屏幕上删除字符,它只会将光标移回你的位置

必须打印一个空格来删除字符)。返回一个char cout<<

char(8)<< char(''')<< char(8)。

如果你的程序只能在PC上运行,你可以使用一点装配

来在屏幕上移动光标。中断21有几个函数

,可让你控制光标。


Ali R.


" Koen Janssens" <公斤***** @ sandia.gov>在消息中写道

新闻:BBE927F3.2E2D%kg ***** @ sandia.gov ...

任何人都可以给我一个如何写进展的例子C ++中的指标使用标准库cerr或cout?

我的问题是我不知道如何将输出流重置为行的开头
,所以只是那些信息会很好。

谢谢 - Koen



" Koen Janssens" <公斤***** @ sandia.gov>写了...

有人能举例说明如何使用标准库cerr或cout在C ++中编写进度指示器吗?

我的问题是我不知道如何将输出流重置为该行的起始
,所以只需要该信息就可以了。




输出''\ n ''是开始换行的常用方法(

字符的名称是换行符)。但是,没有与系统无关的方式

重置为输出流到行的开头。很多

系统会像你预期的那样回复''\ r'',但是'__________

保证是可移植的。


Victor


" Koen Janssens" <公斤***** @ sandia.gov>在消息中写道

新闻:BBE927F3.2E2D%kg ***** @ sandia.gov ...

任何人都可以给我一个如何写进展的例子C ++中的指标使用标准库cerr或cout?

我的问题是我不知道如何将输出流重置为行的开头
,所以只是那些信息会很好。




使用回车符(\ r)而不是换行符(\ n)


Can anybody give me an example on how to write a progress indicator in C++
using the standard library cerr or cout?

My problem is I do not know how reset the output stream to the beginning of
the line, so just that information will do fine.

Thanks - Koen

解决方案

I don''t think that c++ has anything like that. You could possibly use
either a carriage return char(13) (without the line feed) or use backspace
char(8) to backspace your way back to the end of the line (backspace doesn''t
remove the character from the screen, it only moves the cursor back you
would have to print a space to remove the char). to go back one char cout <<
char(8) << char('' '') << char(8).
If you''re program is going to only run on a PC you can use a bit of assembly
to move the cursor around on the screen. There are a couple of functions
for interrupt 21 that let you control the cursor.

Ali R.

"Koen Janssens" <kg*****@sandia.gov> wrote in message
news:BBE927F3.2E2D%kg*****@sandia.gov...

Can anybody give me an example on how to write a progress indicator in C++
using the standard library cerr or cout?

My problem is I do not know how reset the output stream to the beginning of the line, so just that information will do fine.

Thanks - Koen



"Koen Janssens" <kg*****@sandia.gov> wrote...

Can anybody give me an example on how to write a progress indicator in C++
using the standard library cerr or cout?

My problem is I do not know how reset the output stream to the beginning of the line, so just that information will do fine.



Outputting ''\n'' is a common way to begin a new line (the name of the
character is "newline"). However, there is no system-independent way
to "reset to output stream to the beginning of the line". Many of
the systems respond to ''\r'' as you probably expect, but that''s _not_
guaranteed to be portable.

Victor


"Koen Janssens" <kg*****@sandia.gov> wrote in message
news:BBE927F3.2E2D%kg*****@sandia.gov...

Can anybody give me an example on how to write a progress indicator in C++
using the standard library cerr or cout?

My problem is I do not know how reset the output stream to the beginning of the line, so just that information will do fine.



Use a carriage return ("\r") instead of a newline ("\n")


这篇关于终端进度指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆