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};
This works OK:
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.
<array>
<initializer_list>
Copyright © 2021 Jogjafile Inc.
This works OK:
float floatTab[3] = {12f, 0.5f, 3f}; float* ptr = floatTab;