First of all don't forget to return 0 from main. Compile your code with all the warnings enabled.

In terms of making sure you only read in numbers you basically have to read the input as a string...