☰
d2jsp
Rules
Help
Forum Gold FAQ
Live Streams
Photo Gallery
Hourly Raffle
Ladder Slasher
Log In
Register
Log In
Register
Account Recovery
Resend Validation Email
d2jsp Forums
>
Off-Topic
>
Computers & IT
>
Programming & Development
> C++ Handling Input
Add Reply
New Topic
New Poll
Views: 223
Replies: 3
Track Topic
oOn
Member
Posts: 5,988
Joined: May 6 2006
Gold
:
30.00
#1
Oct 22 2013 02:03pm
When you have a variable declared
int c;
and you write
cin >> c;
Whats the best way to handle the case where a user inputs a character(s)?
This post was edited by oOn on Oct 22 2013 02:03pm
Azrad
Member
Posts: 10,812
Joined: Oct 15 2009
Gold
:
Locked
Warn: 20%
#2
Oct 22 2013 03:26pm
Put the user input into a string, then test it to see if it can be converted to integer, just an idea.
This post was edited by Azrad on Oct 22 2013 03:28pm
labatymo
Member
Posts: 2,757
Joined: Nov 26 2007
Gold
:
1,214.81
#3
Oct 23 2013 07:16am
if (cin >> c){
// was an integer
}else{
//wasn't an integer
}
SelfTaught
Member
Posts: 1,358
Joined: Dec 30 2012
Gold
:
0.10
#4
Oct 23 2013 07:40am
Isdigit()
Go Back To
Programming & Development
Topic List
Add Reply
New Topic
New Poll
© 2003-2026 d2jsp
Contact