char*** get_func(int size, char** arr) {
int i, num;
char*** ans = (char***)malloc(size*sizeof(char**));
for(i = 0; i < size; i++) {
scanf("%d", &num);
*(ans + i) = arr + (num - 1);
}
return ans;
}
What I want to achieve of this function is, for example, the arr = ["a", "b", "c"] and size = 2, then scanf get the index of the element in arr, num = 1 and 3, the returned ans should be ["a", "c"]. But I dont know where the bug is in my code, it just return the ["a", "b"].