return array in c
// fill a preallocated buffer provided by 
// the caller (caller allocates buf and passes to the function)
void foo(char *buf, int count) {
    for(int i = 0; i < count; ++i)
        buf[i] = i;
}
int main() {
    char arr[10] = {0};
    foo(arr, 10);
    // No need to deallocate because we allocated 
    // arr with automatic storage duration.
    // If we had dynamically allocated it
    // (i.e. malloc or some variant) then we 
    // would need to call free(arr)
}