cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Error check for account# starting with a
Error check for account# starting with any 0 int.
Aug 16, 2011 at 5:27am UTC
Starmond
(1)
I have to error check if a user inputs any number with a 0 or 00345. The account number cannot begin with any 0 at all and account number needs to be 5 digits long. I am at a loss on how to even begin to do this. Can anyone help?
Aug 16, 2011 at 5:44am UTC
closed account (
DSLq5Di1
)
Fetch your input as a string, check the length is 5 and the first character is not 0, convert to an integer using a stringstream if needed..
http://www.cplusplus.com/reference/string/string/
http://www.cplusplus.com/reference/string/getline/
http://www.cplusplus.com/reference/iostream/stringstream/stringstream/
Topic archived. No new replies allowed.