Closed
Description
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();
}
Activity