Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,456 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,908 people online right now. Registration is fast and FREE... Join Now!




Clearing a bad input in a console window

 
Reply to this topicStart new topic

Clearing a bad input in a console window

anonymous89
8 Aug, 2008 - 11:33 PM
Post #1

New D.I.C Head
*

Joined: 12 Jun, 2008
Posts: 5

--------------------------------------------------------------------------------

Hi, can I know the coding for the below situation.

Basically, I want to ask the user to enter the desired data, for instance name. Then I proceed to ask the user to enter his age (between a certain range). The problem is that how do I prompt the user to reenter the correct data, while clearing the data that has been previously entered and displayed, and at the same time, make sure that his name is not cleared.

It goes something like this.................


__________________________________________________ _______________
Please enter your name: Jack Johnson

Please enter your age : 900

You entered over 100 years. Enter again.
__________________________________________________ _______________



Since data entered is not in the allowable range, prompt the user to enter again.

__________________________________________________ _______________

Please enter your name: Jack Johnson

Please enter your age :

__________________________________________________ _______________

All I know is that only one command can be used to clear the screen, ie, system("cls"). But if I use this, it will clear the first line as well.

Please help.

User is offlineProfile CardPM
+Quote Post

fountainoftruth
RE: Clearing A Bad Input In A Console Window
9 Aug, 2008 - 01:42 AM
Post #2

D.I.C Head
Group Icon

Joined: 4 Dec, 2007
Posts: 73


My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Clearing A Bad Input In A Console Window
9 Aug, 2008 - 06:56 AM
Post #3

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
Well, there are platform specific things that you can do to clear the console window. What platform are you working on?

Somewhere on this forum there is another thread on just such an issue on windows. I wrote a special function to clear all rows below a given row.

If you are on windows see this post. It is a function to clear the data from Row1 to Row2...
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 03:35PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month