I want to make a program that only takes integer. and if someone write any alphabet, then it will ask again for that number.
For Example:
Enter Age:as
Invalid Number
Enter Age:
I want to make a program that only takes integer. and if someone write any alphabet, then it will ask again for that number.
For Example:
Enter Age:as
Invalid Number
Enter Age:
Jump to PostYou have two options:
- Read a line of input, parse it, and determine whether it matches your program's expectations. If not, print an error and request input again until you get what you want.
- Use a non-standard, non-portable library to read raw input from the keyboard. With this you …
You have two options:
Can You Please make a small sample program for me.. PLEASE i am a new programmer.. and don't know anything...
http://www.daniweb.com/tutorials/tutorial45806.html
There are links there for "Read an Integer from the User..."
(This would be approach (1) from above.)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.