With scanf there's, usually, a direct way to take formatted input:
1) line with a real number higher than 0, and less than 1. Ending on 'x', e.g: 0.32432523x
scanf("0.%[0-9]x", &number);
2) line represents an addition in the format :30+28=fifty-eight
scanf(":%d+%d=%99s", &number1, &number2, &total);
What is the cin solution, using only the standard library?
You can make a simple class to verify input.
usage:
Use the >> operator to read from cin.
It's not as good as scanf because you'd have to verify any literals that were in the scanf string yourself. Doing it with streams will almost certainly be a lot more lines of code than scanf.
I would use scanf.