944,049 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 763
  • C++ RSS
Sep 11th, 2007
0

error checking help

Expand Post »
I need to error check a user input and it must be a value between 0 and 13 whole numbers only. it will be stored in a int variable using the cin function. I dont remember how to do this since i have not taken a c++ course in 3 years. This assignment is using top down progamming, not object oriented programming.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gmoli is offline Offline
3 posts
since Sep 2007
Sep 11th, 2007
0

Re: error checking help

perhaps this will help jog your memory
Last edited by Duki; Sep 11th, 2007 at 2:03 pm.
Reputation Points: 817
Solved Threads: 32
Nearly a Posting Virtuoso
Duki is offline Offline
1,474 posts
since Jun 2006
Sep 11th, 2007
0

Re: error checking help

Click to Expand / Collapse  Quote originally posted by Duki ...
perhaps this will help jog your memory

I looked at the tutoral and have not seen anything about error checking i think I have the basic concept of c++ I have completed the top down course at my school. I am now enrolled in opject oriented programing class. My first assigment is a review from my last class and my notes on error checking are terrible. that is my fault but i dont have anything to look at to see how to set this one up. any help you can give would be greatly appriciated. I am not sure what this text box means by surround code could you briefly explain this to me as well. this is the first time i have ever posted a thread. thankyou soo much.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gmoli is offline Offline
3 posts
since Sep 2007
Sep 11th, 2007
0

Re: error checking help

when/if you paste any of your code in a reply you need to do it like this

[code.]

\\code goes here

[/code.]

of course, you want to take out the '.' after the word code which makes your reply look like this:

C++ Syntax (Toggle Plain Text)
  1.  
  2. #include <iostream>
  3. ...
  4. return 0 ;
etc.


As for the error checking, consider this. If you wanted to check that 'x' is less than 10 but greater than 0, you could use the following construct:

C++ Syntax (Toggle Plain Text)
  1. if ( x > 0 && x < 10 )
  2. cout << "Excellent!" << endl ;
  3. else
  4. {
  5. cout << "Invalid Input!! -- Exiting program!!" << endl ;
  6. exit ( 1 ) ;
  7. }

So now, what else could you check with the if/else statements and how?
Does this help any?
Reputation Points: 817
Solved Threads: 32
Nearly a Posting Virtuoso
Duki is offline Offline
1,474 posts
since Jun 2006
Sep 11th, 2007
0

Re: error checking help

yes i was just going about it from the wrond direction very helpfull thankyou very much for your time and wisdom
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gmoli is offline Offline
3 posts
since Sep 2007
Sep 11th, 2007
0

Re: error checking help

welcome.
Reputation Points: 817
Solved Threads: 32
Nearly a Posting Virtuoso
Duki is offline Offline
1,474 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Deciding return type of a function at runtime
Next Thread in C++ Forum Timeline: C++ BGI Graphic Help!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC