The easiest way is by making use of sscanf(). Assuming you have the user input in an array of char buf with its starting tabs, spaces and letter symbols removed, you can simply call on
retval=sscanf(buf, "%d", &intval);
If retval equals 1, you have bagged an integer, the value of which is in intval. The downside is that it breaks down when faced with input which exceed the capacity of int, and ignores any remaining text in the input line after a non-number symbol was parsed. Also, sscanf() will not tell you what the user input was when it returns 0 indicating no match was made. In this case, your best bet is to simply put out a 0x07-character (\b if memory serves me) for the terminal beep, warn the user with a text, and redo the input.