Implementing Backspace in a string

I’ve got a project which features a keyboard. When I press keys each character is added to a string. I want it to be so that when I press backspace the last character is earesed. I’ve tried a few things but with no joy. Any help would be greatly appreciated (I’m a student so very new). Below shows the char where each character is being stored.

char Msg_Writing[120] = “”;

and this is how I am adding each “Selected Key” to that string:

char tmp[2] = {SelectedKey,0};
strncat(Msg_Writing, tmp, sizeof(Msg_Writing)-1);

Hello Edward,

The following might work:

 char Msg_Writing[120] =  { 0 };
    
//and this is how I am adding each “Selected Key” to that string:
    
char tmp[2] = {SelectedKey, 0}; // null-terminated string
    
if (strlen(Msg_Writing) < sizeof(Msg_Writing) - 2 /*space for this new char and terminating null-char*/) {
    if ((SelectedKey == 0x08 /*ASCII code of Backspace*/) && (strlen(Msg_Writing) > 0))
        Msg_Writing[strlen(Msg_Writing) - 1] = 0;   // deletes last char (overwrites it with terminating null-character)
    else   
        strncat(Msg_Writing, tmp, 1);   // appends the first num (1) characters of source (`tmp`) to destination (`Msg_Writing`), plus a terminating null-character.
}

Best regards, Zoltan