This is the block of code
{
static float f = 0.0f;
static int counter = 0;
ImGui::Begin("Hello, welcome to Life Simulator!");
if (ImGui::Button("Dealership"))
ImGui::OpenPopup("Dealership");
// Always center this window when appearing
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
if (ImGui::BeginPopupModal("Dealership", NULL, ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::Text("Welcome to Rob's Dealership");
ImGui::Separator();
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
ImGui::Text("These are the vehicles in store");
ImGui::PopStyleVar();
ImGui::Text("Model: %s, Color: %s, Price: %s", Slot1.Model, Slot1.Color, Slot1.Price);
if (ImGui::Button("Leave", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
ImGui::EndPopup();
}
ImGui::End();
}
After I click on the Dealership button the program stops and I get
Exception thrown at 0x00007FFA8C9E33CD (ucrtbased.dll) in ConsoleApplication2.exe: 0xC0000005: Access violation reading location 0x0000000000002EE0.
I tried moving where ImGui::BeginPopupModal
is, but when I clicked on the button nothing would happen at all
Edit: I've narrowed it down to ImGui::Text("Model: %s, Color: %s, Price: %s", Slot1.Model, Slot1.Color, Slot1.Price);
The Model and Price variables are std::strings
Edit 2: I did get it figured out by changing the Model and Color variables to const char* and changing ImGui::Text("Model: %s, Color: %s, Price: %s", Slot1.Model, Slot1.Color, Slot1.Price);
to
ImGui::Text("Model: %s, Color: %s, Price: %i", Slot1.Model, Slot1.Color, Slot1.Price);
User contributions licensed under CC BY-SA 3.0