Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ostream & position

Posted on 2002-03-17
3
Medium Priority
?
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

618 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