I wonder how to convert a float array to a float* I have this situation :
float* floatTab = {12f, 0.5f, 3f};
It gives me an error here. but if I write it like this float floatTab[3] = {12f, 0.5f, 3f};
it compiles alright.
这样可以正常工作:
float floatTab[3] = {12f, 0.5f, 3f}; float* ptr = floatTab;
Prefer STL containers instead of C arrays (or others RAII-conform classes):
const std::array<float, 3> array = { 1.f, 2.f, 3.f };
float *ptr = &array[0];
Don't forget to include <array>
and <initializer_list>
to compile this code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.