shellmath/c/sum.c
2023-09-30 16:55:18 +01:00

18 lines
303 B
C

#include <stdio.h>
int main(int argc, char **argv) {
int buf;
int acc;
int err;
for(int i=1;i<argc;i++) {
err=sscanf(argv[i], "%i", &buf);
if(err!=1) {
fprintf(stderr, "sscanf error: not an integer.\n");
return 1;
}
acc+=buf;
}
printf("%d\n",acc);
return 0;
}