I'm writing a small C program to do some number crunching, and it needs to pass around arrays between functions. The functions should accept and return pointers, right?
For example, this (I know it may not be the most efficient thing):
int* reverse(int* l, int len) {
int* reversed = malloc(sizeof(*reversed)*len);
int i, j;
for (i = 0, j = len-1; i < len; i++, j--) {
reversed[j] = l[i];
}
return reversed;
}
Am I using pointers right?