I got my code working, but i feel as if there is a faster way to do this especially in my function copy. here is my code. can this be any faster? this is in C btw. Also when i return cpy from the function does it delete the dynamic memory since its out of scope? I don't want to have memory leaks :P
#include <stdio.h>
#include <stdlib.h>
double *copy(double a[], unsigned ele);
int main(){
    double arr[8], *ptr;
    unsigned i=0;
    for(;i<7;i++){
        scanf_s("%lf", &arr[i]);
    }
    ptr=copy(arr, 8);
    for(i=0;i<7; i++)
        printf("%f", ptr[i]);
}
double *copy(double a[], unsigned ele){
    double *cpy= malloc(sizeof(double)*ele);
    int i=0;
    for(;i<ele; i++)
        cpy[i]=a[i];
    return cpy;
}