Won't all of these just print out
Your Position: X1
Your Position: X2
Your Position: X3
Your Position: X4
..
..
..
etc all the way to Xreally big number?
I just want the program to print 1 line to the console during the
entire program, and then go back and basically place the cursor where
the numbers start and write the current value.
Someone suggested using \b to backspace, but that ends up adding some
really wierd cursus images and flickering.
Rolf Magnus wrote:[color=blue]
> Victor Bazarov wrote:
>[color=green]
> > Rolf Magnus wrote:[color=darkred]
> >> Victor Bazarov wrote:
> >>
> >>>
gtpilot@gmail.com wrote:
> >>>> I have a program that is going to return position data several
> >>>> times a second. Instead of printing this data to the screen on new
> >>>> line every time, I would like to simply have the program print
> >>>> "Position: XX" on one line, adn then update the XX every time there
> >>>> is new data.
> >>>
> >>> Outputting
> >>>
> >>> std::cout << "\rPosition: " << yourpositionvariable;
> >>>
> >>> inside your loop will probably do what you want.
> >>
> >> The stream should be flushed at the end. Otherwise, the update is
> >> probably done too late:
> >>
> >> std::cout << "\rPosition: " << yourpositionvariable << std::flush;[/color]
> >
> > There is no guarantee that \r does what the OP needs, but if it does,
> > it most likely will do it without flush (IME, anyway).[/color]
>
> I have no idea if \r usually flushes the stream, but if it does, it will do
> it before the line gets written, not afterwards. This might not be very
> relevant if you print the line "several times a second", but I would add
> the flush anyway.[/color]