Skip to content

InputTextMultiline crashes when clicked on #4657

@nulliousp

Description

@nulliousp

I am attempting to read and write to a file with ImGui::InputTextMultiline but right now I just want to get it to render text to it. For some reason, it is not working and shows the first 4 characters correctly then just random characters.

 {
    ImGui::Begin("File Editor");
    std::ifstream file(path.string());
    std::string fileText;
    std::string tempString;

    while (std::getline(file, tempString)) {
        fileText.append(tempString);
    }

    size_t size = sizeof(fileText) * 2;
    char* newText = new char(size);
    char text[sizeof(newText) / sizeof(newText[0])];
    for (int a = 0; a < sizeof(*newText) / sizeof(newText[0]); a = a + 1) {
        text[a] = newText[a];
    }
    std::strncpy(text, fileText.c_str(), sizeof(text));

    ImGui::InputTextMultiline("", text, IM_ARRAYSIZE(text));
    ImGui::End();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions