[Solved] Convert double * to double [9] in C [closed]


#include <stdio.h>
#include <string.h>

typedef struct dbl9 {
    double array[9];
} Dbl9;

Dbl9 fun(double *in){
    Dbl9 ret;
    memcpy(ret.array, in, sizeof(ret.array));//There can be no assurance that <in> the correct
    return ret;
}

int main(){
    double array[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
    Dbl9 dbl9= fun(array);
    int i;
    for(i=0;i<9;++i){
        printf("%f\n", dbl9.array[i]);
    }
    return 0;
}

1

solved Convert double * to double [9] in C [closed]