diff options
author | Ian C <ianc@noddybox.co.uk> | 2010-11-08 15:57:24 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2010-11-08 15:57:24 +0000 |
commit | 5f7fdc1a37689968a3856f86e8388e3cda6c2ebd (patch) | |
tree | 272d7096c90a80b0afa1b1c2bebd9d44d15a04c7 | |
parent | 85c492a2bd5bb1a2619ad709f038576d30262fb5 (diff) |
Tided up total.c
-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; } |