// This program demonstrates the functio atoi inside stdlib.h // This function converts Ascii (A) to Integer (I) - useful! // In this function, we will print out all the command line arguments // given and then add them together to give the sum of the command // line arguments #include // Include standard library stdlib.h to have access to tehe atoi function #include int main (int argc, char *argv[]) { int sum = 0; // Remember that the command line arguments are all strings, so if you // need to do mathematical operations, you will need to convert them // to numbers // You can do this with a really handy function atoi() in the stdlib.h library! printf("There are %d arguments", argc); // Let's print out all the command line arguments given and then add // them together to give the sum of the command line arguments for (int i = 1; i < argc; i++) { sum = sum + atoi(argv[i]); } printf("The sum of the arguments is %d\n", sum); return 0; }