how to clear cin on screen right after entering a number


I was wondering how to clear the cin right after the user inputs whatever it may be.

For instance, when the user inputs the number 23, the number wont appear on stream after hitting the enter key when submitting the number to the program.

I'm asking because I'm trying to write a program where after you enter a number it aligns to their respected position.
i.e
----------Column1------Column2------Column3
Row1-----Num1----------Num2-----------....
Row2-------...---------------...


What I was going to do is when they input the number, ill have it cout in their respected place.

I just dont want it to look like this after they finish entering all the numbers

Num1------\
Num2--------\
...---------------All these numbers shouldn't show in the stream
... ------------/
... ----------/

----------Column1------Column2------Column3
Row1-----Num1----------Num2-----------....
Row2-------...---------------...


edit: added dashes to evenly space them out..
Last edited on
The thing about making interfaces with any of the libraries in C++ is that you are in fact clearing and redrawing the entire screen everytime something changes. Some of them hide this fact from you but they still do it.

So the answer to your question is to clear the entire screen (there is no right way to do this) and redraw everything.
Ahh, it didnt get submitted how i had it typed out =\
Sorry if my example looks sloppy. I had them evenly spaced out when I was typing it...
@Computergeek01
is there another way to have my answers line up ?

I can easily tell the user to hit tab several times so it would line up when entering the number but feel like its asking too much from them. What i want them to do is hit enter after inputting the number. But after inputting the first number, the next inputted answer is on a new line.
Use the [tt][/tt] tags for monospace font.

You can't do much about them hitting enter. If they hit enter, the cursor will naturally go to the next line unless you catch it before sending it to the console somehow. If you think about it, even spreadsheet applications use Tab to move across rows, and Enter to move down columns.
I should point out that redrawing the screen is not some monumental task, it is done really fast and hundreds of times a second on most applications. It's different but learning new things is half the fun with programming.
Topic archived. No new replies allowed.