将int数组更改为C中的float数组 [英] Change int array to float array in C
本文介绍了将int数组更改为C中的float数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
然而,假设你已经声明了你的整数数组,你可以尝试这样的事情:
//实例化浮点数组
float fArray [sizeOfIntArray];
//遍历整数数组中的每个元素,并将其复制到float数组中作为浮点数
for(int i = 0; i< sizeOfIntArray; ++ i){
fArray [i] =(float)iArray [i];
}
Does anyone know how to turn an integer array into a float array?
解决方案
Your question is not worded well; however, assuming you have already declared your integer array, you could try something like this:
// instantiate float array
float fArray[sizeOfIntArray];
// step through each element of integer array, and copy into float array as float
for(int i = 0; i < sizeOfIntArray; ++i) {
fArray[i] = (float)iArray[i];
}
这篇关于将int数组更改为C中的float数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文