This is my first time programming in c. I have this code that is supposed to take whatever numbers the user types in until the enter a 0. Then it should add them all up. For example if they type in 1, then 2, then 3, and finally 0, it should print out 6. But for some reason it does not add the last value. In the case I mentioned it would print 3 instead of 6.
#include <stdlib.h>
#include <stdio.h>
static char syscall_buf[256];
#define syscall_read_int() atoi(fgets(syscall_buf,256,stdin))
main()
{
int input;
input = syscall_read_int();
int result = 0;
input = syscall_read_int();
while (input != 0){
result = result + input;
input = syscall_read_int();
}
printf("%i\n", result);
}
input = syscall_read_int();line.