I want to process user input as an integer, but it seems as though C has no way to get an int from stdin. Is there a function to do this? How would I go about getting an int
scanf() is the answer, but you should certainly check the return value since many, many things can go wrong parsing numbers from external input...
int num, nitems;
nitems = scanf("%d", &num);
if (nitems == EOF) {
/* Handle EOF/Failure */
} else if (nitems == 0) {
/* Handle no match */
} else {
printf("Got %d\n", num);
}