Example
scanf(format_str, mem_addr_1, mem_addr_2, …);
int x = 0;
int sum = 0;
while (1)
{
int res = scanf("%d", &x);
if(res == EOF) break;
sum += x;
}
printf("Sum is %d\n", sum);
Note, if getting a single character then you need to put in a space:
int res = scanf(" %c", &a);