Hello! I haven’t been able to find any examples on how to implement a character callback function, so I am here to ask for review about my implementation. I want to store all the printable characters in a std::wstring if the player has opened the chat window. This is how I implemented the function, but it seems kind of stupid to me:
Note that your original code has a buffer overrun issue as the array ‘input’ does not have a null terminator. You need to have it one longer than the characters inside with a 0 at the end. Additionally you don’t need to ‘new’ a small array, you can declare it on the stack as: ‘wchar_t input[2];’, and that way you don’t have to delete it.