we define int a and waiting user to input and we assing it to a but what if user's input is not a integer ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

we define int a and waiting user to input and we assing it to a but what if user's input is not a integer ?

C++ Input

11th May 2017, 10:59 PM
SeciuS
3 Answers
+ 6
Then the program crashes as an int cannot be assigned as a string. Use a try catch to handle this.
11th May 2017, 11:09 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
Yes. As Rrestoring said, always check the inputs with try
11th May 2017, 11:16 PM
Adrià
Adrià - avatar
+ 2
Ty so much guys
11th May 2017, 11:17 PM
SeciuS