When reading in from a file as you are doing, all data is seen as a string. You must check to see if the string is a number. Here is a way to convert a string to an integer (IF THAT STRING IS AN INTEGER): atoi() function
Be careful though, you must pass it a c-string.