summaryrefslogtreecommitdiff
path: root/total.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2010-11-08 15:57:24 +0000
committerIan C <ianc@noddybox.co.uk>2010-11-08 15:57:24 +0000
commit5f7fdc1a37689968a3856f86e8388e3cda6c2ebd (patch)
tree272d7096c90a80b0afa1b1c2bebd9d44d15a04c7 /total.c
parent85c492a2bd5bb1a2619ad709f038576d30262fb5 (diff)
Tided up total.c
Diffstat (limited to 'total.c')
-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;
}