diff options
-rw-r--r-- | total.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -1,16 +1,17 @@ +#include <stdlib.h> #include <stdio.h> int main(int argc, char*argv[]) { - int tot=0; + unsigned long long tot=0; char s[128]; - gets(s); - while(!feof(stdin)) - { - tot+=atoi(s); - gets(s); - } + while(fgets(s, sizeof s, stdin)) + { + tot += strtoull(s, NULL, 0); + } - printf("%d\n",tot); + printf("%llu\n", tot); + + return EXIT_SUCCESS; } |