?
Solved

Writing to standard output in C++

Posted on 2003-03-09
3
Medium Priority
?
223 Views
Last Modified: 2010-04-01
I want to write to the standard output, but I want to be able to write to the same area more than once.
So if I have a cout<<"message1", and I have more than 1 message, I want to be able to cout<<"message #" in the same spot in the console that message1 was outputted to the screen.  I think I have to decrement the stream pointer to the stdout, but I'm not sure how to do it.  Is it even possible?
Thank you,
K
0
Comment
Question by:KayodeCS_BU
[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 8

Expert Comment

by:Exceter
ID: 8100562
0
 
LVL 5

Accepted Solution

by:
Kocil earned 1000 total points
ID: 8100594
The easiest way is :
  cout<<"message 1\r";
  cout<<"message #\r";

If you use Borland compiler, you have more options by using <conio.h> and use something like

  gotoxy(1,1);
  clreol();
  cprintf("message 1");

 
0
 

Author Comment

by:KayodeCS_BU
ID: 8105599
Ok, it didn't work at first, but I flushed the stdout buffer,cout<<flush;, between the two messages and I got it to work.  Thank you, I've never seen the \r before.
K
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 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 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.
Suggested Courses

770 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