For some reason, my function is only returning the first element in my array and I cannot figure out why the rest of the array goes out of scope. The function takes two integer
You can't return a pointer to an automatic local variable. total is an automatic local variable and it doesn't exist after function body executed.
total
Pointer to static local variable or dynamically allocated variable can be returned. Change int total[10]; to
static
int total[10];
int *total = malloc(10 * sizeof(int));