From 5f7fdc1a37689968a3856f86e8388e3cda6c2ebd Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 8 Nov 2010 15:57:24 +0000 Subject: Tided up total.c --- total.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'total.c') diff --git a/total.c b/total.c index bfdd7d0..78e2f0f 100644 --- a/total.c +++ b/total.c @@ -1,16 +1,17 @@ +#include #include 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; } -- cgit v1.2.3