C-通过memcpy复制数组



我看到有很多关于memcpy的文章,但我找不到解决问题的解决方案。有人可以看到为什么复制操作不起作用吗?

float MeanFilter(const volatile float *Array, volatile float Dist){
float Avg = 0.0;    // Variable used to calculate the average distance value
float Sorted[MaxDistArray]; // Array used to contain the sorted array
printf("n");
int j;
for(j = 0; j < 20; j++){
    if(j == 10) printf("n t");
    printf("%d: %f, ", j+1, Array[j]);
}
memcpy(Sorted, &Array[0], sizeof(float));
Sort(Sorted);   // Sort the array of distances values
printf("n");
for(j = 0; j < 20; j++){
    if(j == 10) printf("n t");
    printf("%d: %f, ", j+1, Sorted[j]);
}

idd @ronald是解决方案的一部分

memcpy(Sorted, Array, sizeof(float)*MaxDistArray);

thx!

最新更新