Solved

ostream & position

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 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

25 Experts available now in Live!

Get 1:1 Help Now