#include <stdio.h>
#include <stdlib.h>

int **split_array(const int *s, int length) {
	// the array containg the two pointers to the even and odd arrays
	int **complete_arr = malloc(sizeof(int*)*length);
	// even array 
	int *even_indx = malloc(sizeof(int)*length);
	// odd array 
	int *odd_indx = malloc(sizeof(int)*length);
	for (int i = 0; i < length; i++) {
		if (i % 2 == 0) {
			even_indx[i] = s[i];
		}
		else {
			odd_indx[i] = s[i];
		}
	}
	complete_arr[0] = even_indx;
	complete_arr[1] = odd_indx;
	return complete_arr;
}

/* Return a pointer to an array of ints with size elements.
   - strs is an array of strings where each element is the string
     representation of an integer.
   - size is the size of the array
 */

int *build_array(char **strs, int size) {
	// Create dynamic array
	int *arr = malloc(sizeof(int)*size);
	// Make a temp copy of arr (to create aliasing and add stuff to arr)
	// int *arr_copy = arr;
	// Convert string to integers
	for (int i = 0; i < size; i++){
    arr[i] = strtol(strs[i], NULL, 10); // Something is wrong here
	}
	return arr;
}


int main(int argc, char **argv) {
    /* Replace the comments in the next two lines with the appropriate
       arguments.  Do not add any additional lines of code to the main
       function or make other changes.
     */
    int *full_array = build_array(argv, argc);
    int **result = split_array(full_array, argc);

    printf("Original array:\n");
    for (int i = 0; i < argc - 1; i++) {
        printf("%d ", full_array[i]);
    }
    printf("\n");

    printf("result[0]:\n");
    for (int i = 0; i < argc / 2; i++) {
        printf("%d ", result[0][i]);
    }
    printf("\n");

    printf("result[1]:\n");
    for (int i = 0; i < (argc - 1) / 2; i++) {
        printf("%d ", result[1][i]);
    }
    printf("\n");
    free(full_array);
    free(result[0]);
    free(result[1]);
    free(result);
    return 0;
}
Should have the following output when compiles
$ ./split_array 1 2 3
Original array:
1 2 3
result[0]:
1 3
result[1]:
2