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
The standard library function scanf is used for formatted input:
%d int (the d is short for decimal)
#include
int main(void)
{
int number;
printf("Enter a number from 1 to 1000: ");
scanf("%d",&number);
printf("Your number is %d\n",number);
return 0;
}