Hi fellows, i would like how to stop user to input char in integers? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Hi fellows, i would like how to stop user to input char in integers?

13th Oct 2022, 3:55 PM
light angel
light angel - avatar
2 Respostas
+ 2
You cannot stop users from inputting nonsense. You can only validate the input. E.g. the way proposed by TomƔs Ribeiro
13th Oct 2022, 5:56 PM
Ani Jona šŸ•Š
Ani Jona šŸ•Š - avatar
+ 1
You can do a while loop, inside you read as a "string" and check if the string can be converted to an integer, if so you break the loop, if not you keep on the loop.
13th Oct 2022, 5:02 PM
TomƔs Ribeiro
TomƔs Ribeiro - avatar