[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ostream & position

Posted on 2002-03-17
3
Medium Priority
?
227 Views
Last Modified: 2010-04-01
Hi Expert,

Having this piece of code:

while (...)
{
     cout << setw(16) << x;
}

Need the "x" to be printed at the same position at the window for all the iterations.

Can not find any flag/manipulator for that,
Can you help with this ?

TIA,
Oren.
0
Comment
Question by:orenm
3 Comments
 
LVL 2

Accepted Solution

by:
LoungeLizard earned 300 total points
ID: 6874875
I suppose you mean console, and not window?

Well, there would be specific methods for specific platforms, but on DOS/Windows you could try using the "backspace" character and output that to delete the previous value before writing the new one, something like (crude, could be improved, I s'pose):

char * del = new char[17];
memset(del,0x08,16);
del[16]=0;

Then:

while (...)
{
    cout << del;
    cout << setw(16) << x;
}


0
 

Author Comment

by:orenm
ID: 6878345
Thanx
0
 
LVL 11

Expert Comment

by:griessh
ID: 6955411
Dear orenm

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "LoungeLizard"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question