D
D
DarkPrometheus2018-11-06 19:27:01
C++ / C#
DarkPrometheus, 2018-11-06 19:27:01

How to check the correctness of the entered data in c++?

Good afternoon, I just started learning C ++ and came across a problem: How to find out that the user has entered the correct data? Those. if :

double var;
cin >> var;

In this case, the user entered something similar (12a; .145; er125.2; 2. ;--12; etc. ).
I didn’t find an unambiguous solution on the forums, someone offers cin.fail (), someone offers constant expressions, others for symbolic checking (here is my code implementation ).
I would be glad if someone could suggest a solution to the problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question