Hi there! I am using the Jumping into C++ book as a guide to start writing C++. In the first examples, we are asked to read in some numbers and print them out. If I set the variable type to read to an int, like this: cin >> my_int;
But then when prompted to enter the input I type 2.2 (not an integer), then the rest of the line (the ".2") is stored in the input buffer and screws up later requests for data.
Could someone please recommend a good way to safely get input from the command line, check it type correctness, and throw away extra data?
thanks so much!