I need to accept an array of integers from the command line, such as: ./test 2 9 -5 17
Currently I have:
int main(int argc, int *argv[])
And then loops to find the two numbers within this array that create the maximum value possible starting with argv[1]. Obviously this does not work. Do I need it to be:
int main(int argc, char *argv[])
and then parse this? I am not sure how to covert characters to integers in C.
Thanks,
atoi()orstrtol()will work to convert a string to an intintoflong longor maybe not. It would be illuminating to know OP's thoughts on the coding goals.