|
-
December 20th, 2002, 10:03 AM
#1
Simple iostream format question
Hello,
How can output to iostreams (example std::cout) be wrapped around and appear on the same line?
In particular, I would like to print some ticker sequence like
Number: 0.0
Number: 0.1
Number: 0.2
all on one line such that the "Number: " part remains steady and the decimal ticker part counts up. I guess the ideal solution would only print the "Number: " part once and cleverly back up over the decimal ticker part. I tried some stuff with '\r', but didn't like the lack of elegance of the implementation. In addition, with '\r' if the results of previous outputs were longer than the present outputs, then the characters will not be erased and they remain as ghost images.
The sample code prints a separate line for each ticker. Can anyone modify the sample code accordingly for the desired ticker effect. I would really appreciate any help.
Thanks a lot.
Chris.

Code:
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
std::cout << endl;
for(volatile int n = 0; n <= 100; n++)
{
std::cout << "Number: "
<< double(n) / 10
<< endl;
}
return n;
}
You're gonna go blind staring into that box all day.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|