0

How do i format a block of code to only receive data in string form and reject integers and vice versa?

I am trying to format a code that receives (for example) your name and displays an error message if you input numbers...kindly help.

19th Jul 2018, 6:36 PM
Augustine
Augustine - avatar
2 ответов
0
try with cin.fail() after getting user input of string type... I guess it might not fail for 123 as input as 123 might be considered as "123"... If so, try to convert string to double and integer... if it succeed, clear input... -HIH Ketan
19th Jul 2018, 9:28 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
19th Jul 2018, 9:53 PM
Ketan Lalcheta
Ketan Lalcheta - avatar