I'm trying to sum command-line integers. My total is constantly 473. I dont know how to get the right total.
#include <stdio.h>
4 #include <stdlib.h>
5 #include <ctype.h>
6
7 #define MAX 100
8
9 void sum(char *a, int n);
10
11 main (int argc, char *argv[])
12 {
13 int i;
14 char *holder[MAX];
15
16
17 for(i=0; i<argc; i++)
18 {
19 atoi(argv[i]);
*argv=*holder;
20 }
21
22
23
24 sum(*holder,MAX);
25
26 return 0;
27 }
28
29 void sum(char *a, int n)
30 {
31 int i;
32 int f=0;
33
34 for (i=0; i<n; i++)
35 f+=a[i];
36
37 printf("Total: %d\n", f);
38 }