Thanks Jürgen for correcting my comment.
You've prompted me to browse through my venerable copy of Josuttis' The C++ 
Standard Library.
 
respect…

Peter

On 2014-06-01, at 8:00 AM, Juergen Sauermann <[email protected]> 
wrote:
> Hi Peter,
> 
> almost correct. The first comment should be "// may point to an optional 
> string typically containing 6 spaces".
> prompt can be 0 and then no prompt is printed. Otherwise the function pushes 
> the prompt (backwards)
> back into stdin. Whether that works is a matter of the underlying operating 
> system. The man page
> of ungetc() says that only 1 ungetc() char is guaranteed but we push 6. 
> Another question is whether
> an ungetc() into stdin will occur on C++ cin?
> 
> The main use case for this were scripts where it does not matter too much if 
> a prompt is printed
> or not. Note also that pushing chars back into stdin has a different effect 
> than just printing the prompt
> - there are  cases where the prompt should be editable (⍞ I believe).
> 
> /// Jürgen


Reply via email to