How to prevent user from entering number in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to prevent user from entering number in c++?

9th Oct 2017, 7:25 PM
sultan
2 Answers
+ 13
This code prevents Integer input and asks for the correct one which just contains characters. [http://cpp.sh/9j4d] https://code.sololearn.com/ceHKDfo2cgVE/?ref=app
9th Oct 2017, 8:23 PM
Babak
Babak - avatar
+ 3
You can't prevent users from doing anything. You can detect that they have enter something and ignore/complain as needed. Read the input as strings, verify the characters are as expected, and complain or process as desired.
9th Oct 2017, 8:21 PM
John Wells
John Wells - avatar