summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--total.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/total.c b/total.c
index bfdd7d0..78e2f0f 100644
--- a/total.c
+++ b/total.c
@@ -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;
}