Solved

ostream & position

Posted on 2002-03-17
3
196 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 100 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now