Checking an input file

Hi I am learning about streams and I am trying to read numbers from a .txt file but I want it so that if it reads anything other than a number it will print an error message and terminate the program. I can't seem to get this to work, I tried an if statement but the program prints the numbers and when it hits the character it will keep reprinting the last number over and over and the message won't appear! does anyone know how I can ge this to work?
Last edited on
Check the state of the file stream using good().
Topic archived. No new replies allowed.