Hi , I have an issue with some code of mine, I am not sure what’s wrong but I think it has more to do with C++ then ImGui.
Just trying to build a dynamic LisBox().
std::array<const char*, 2> names_array;
for (int i = 0; i < names_array.size(); i++)
{
std::string name = "Object ";
name += std::to_string(i);
names_array[i] = name.c_str();
/// from here names_array[i] gives "Object 0", then "Object 1" , logical.
}
std::cout<< "------- " << names_array[0] << "\n"; /// this prints "Object 1" weird !
ImGui::ListBox("listbox\n(single select)", &listbox_item_current, names_array.data(), 2, 4);
Two elements appear in the listBox , both of them are named “Object 1”.
I don’t get it.
Is there a prefered way to do this kind of thing with imGUI ?