How do I check for a blank entry for numerical input in a C++ program? For example, if my input variable is Qty (an int), how do I check to see if the user simply presses Enter without keying in a value for Qty?
How do I check for a blank entry for numerical input in a C++ program? For example, if my input variable is Qty (an int), how do I check to see if the user simply presses Enter without keying in a value for Qty?
when you use CIN the program will wait for a value to be entered.
When obtaining input from the user it is often best to get the input as a string and then parse it. If you need numerical input then have a look at atoi() which will transform a string to a number.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi