mod.c [src/C] Revision: e2a6e0d96ef5eadfabbb16f7b42e2bbf0e24b385 Date: Mon May 11 14:49:31 MDT 2015
#include <stdio.h>
#include <stdlib.h>
/*
* compile: gcc -o mod.exe mod.c
* run mod.exe 1 2 3 4 5
*/
int main(int argc, char *argv[]) {
int sum = 0, c;
printf("Number of command line arguments passed: %d\n", argc);
printf("Command is %s\n", argv[0]);
for (c = 1; c < argc; c++) {
printf("%d. Command line argument passed is %s\n", c, argv[c]);
sum += atoi(argv[c]);
}
printf("sum = %d\n", sum);
return 0;
}