我看到有很多关于 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);
谢谢!
关于通过 memcpy 复制数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47654861/